2016-06-21 2 views
0

PostgreSQL 데이터베이스에서 삽입 쿼리를 실행하려고하면 이상한 오류가 발생합니다.PostgreSQL not null에 대한 삽입 오류 값

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' 
) 

오류는 다음과 같습니다 : 나는 다음과 같은 쿼리를 실행하고있어

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). 

나는 명확하게 "팁"열 값을 보내고있다, 그래서 내가이야 왜 이해가 안 돼요 이 오류가 발생했습니다. 오류 세부 사항

  1. 하는 이상한 "t"는이 :

    또한, 어쩌면 유용한 몇 가지 추가 정보가 있습니다.

  2. shopping_carts 테이블에 더 많은 열이 있지만 모두 null입니다.
  3. DB에는 shopping_carts 테이블에서 상속 한 3 개의 테이블이 있으며 shopping_carts 테이블에 규칙을 삽입합니다.
  4. 나는

당신이 내게 줄 수있는 모든 도움을 주셔서 감사합니다 DB를 만들 laravel 마이그레이션을 사용하고 있습니다.

+0

데이터베이스를 시드 할 때나 정상적인 사용을 통해 이러한 현상이 발생합니까? 행을 삽입하는 데 사용하는 정확한 코드는 무엇입니까? – aynber

+0

또한 해당 테이블의 전체 정의를 알려주시겠습니까? – jmelesky

+1

''t''는'true'를 나타내는 또 다른 방법입니다 : https://www.postgresql.org/docs/current/static/datatype-boolean.html –

답변

0

해결책을 찾았습니다.

shopping_cart 하위 테이블에 삽입 규칙이 있습니다. 문제는 정의 된 규칙 뒤에 "팁"열을 추가했다는 것입니다.

규칙 쿼리를 다시 실행하여 업데이트해야했습니다. 그것은 그 문제를 해결했습니다.

관련 문제