douxu2467 2016-06-21 16:11
浏览 159
已采纳

PostgreSQL在非空值上插入错误

I'm getting a weird error when trying to execute an insert query on a PostgreSQL database. I'm executing the following query:

insert into "shopping_carts" 
(
"application_version", "charges", "device_id", "device_type", "id", "new_client",
"os_version", "platform_name", "resolution", "shopping_cart_date",
"shopping_cart_date_day", "shopping_cart_date_day_of_week",
"shopping_cart_date_day_of_year", "shopping_cart_date_hour",
"shopping_cart_date_minute", "shopping_cart_date_month",
"shopping_cart_date_numeric", "shopping_cart_date_quarter", 
"shopping_cart_date_quarter_name", "shopping_cart_date_second", 
"shopping_cart_date_week_of_year", "shopping_cart_date_year", "status", 
"store_id", "store_name", "tip", "total_after_discounts", "total_discount", 
"total_items", "user_gender", "user_id", "whim_has_photo", "whim_what", 
"whim_where"
) 
values 
(
2.0, 0.0, '105755B41135E2A6F5C09089EE776BA179A4DD290E27B6DC11AFC94534572BD7', 
'smartphone', 'QWFISFJ23434', true, 'Ubuntu 15.10', 'ios', '1920x1080', 
'2016-06-20 18:42:15', 20, 1, 171, 18, 42, 6, 1466448135, 2, 'Second Quarter', 
15, 25, 2016, 'PROGRESS', 15, 'BOG F. Centro Andino', 0, 0, 0, 0, 'M', 32, 
TRUE, 'Lechona', 'Lechoneria de la esquina'
)

The error is:

Kernel error: ERROR:  null value in column "tip" violates not-null constraint

DETAIL:  Failing row contains (QWFISFJ23434, 0, 0, 0, PROGRESS, null, null, 0, 15, BOG F. Centro Andino, null, null, null, 32, M, Ubuntu 15.10, 1920x1080, 2.0, ios, 105755B41135E2A6F5C09089EE776BA179A4DD290E27B6DC11AFC94534572BD7, smartphone, 2016-06-20 18:42:15, 1466448135, 2016, 6, 20, 2, Second Quarter, 171, 1, 25, 18, 42, 15, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, t, null, null, null, null, null, null).

I'm clearly sending a value for the "tip" column, so I don't understand why i'm getting this error.

Also, there is some additional information that maybe useful:

  1. In the error detail, there is a wierd "t".
  2. The shopping_carts table has more column but they are all nullable.
  3. In the DB exists 3 tables wich inherit from the shopping_carts table, and have insert rules in the shopping_carts table.
  4. I'm using laravel migrations to create the DB

Thank you for any help you can give me.

  • 写回答

2条回答 默认 最新

  • doujiyun0041 2016-06-21 16:40
    关注

    Found the solution.

    I had an insert rule on the shopping_cart child tables. The problem was that I added the "tip" column after the rules where defined.

    I had to execute the rules queries again to update them. That solved the problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)