fix: character and bit columns with fixed length not inserting/updating properly
Fixes the error "value too long for type character(1)" when the char length of the column was bigger than one.
This commit is contained in:
@@ -391,6 +391,22 @@ spec actualPgVersion = do
|
||||
`shouldRespondWith` [json|[{ id: 20 }]|]
|
||||
{ matchStatus = 201 }
|
||||
|
||||
-- https://github.com/PostgREST/postgrest/issues/2861
|
||||
context "bit and char columns with length" $ do
|
||||
it "should insert to a bit column with length" $
|
||||
request methodPost "/bitchar_with_length?select=bit"
|
||||
[("Prefer", "return=representation")]
|
||||
[json|{"bit": "10101"}|]
|
||||
`shouldRespondWith` [json|[{ "bit": "10101" }]|]
|
||||
{ matchStatus = 201 }
|
||||
|
||||
it "should insert to a char column with length" $
|
||||
request methodPost "/bitchar_with_length?select=char"
|
||||
[("Prefer", "return=representation")]
|
||||
[json|{"char": "abcde"}|]
|
||||
`shouldRespondWith` [json|[{ "char": "abcde" }]|]
|
||||
{ matchStatus = 201 }
|
||||
|
||||
context "POST with ?columns parameter" $ do
|
||||
it "ignores json keys not included in ?columns" $ do
|
||||
request methodPost "/articles?columns=id,body" [("Prefer", "return=representation")]
|
||||
|
||||
@@ -384,6 +384,22 @@ spec actualPgVersion = do
|
||||
, matchHeaders = ["Preference-Applied" <:> "missing=default"]
|
||||
}
|
||||
|
||||
-- https://github.com/PostgREST/postgrest/issues/2861
|
||||
context "bit and char columns with length" $ do
|
||||
it "should update a bit column with length" $
|
||||
request methodPatch "/bitchar_with_length?char=eq.aaaaa"
|
||||
[("Prefer", "return=representation")]
|
||||
[json|{"bit": "11100"}|]
|
||||
`shouldRespondWith` [json|[{ "bit": "11100", "char": "aaaaa" }]|]
|
||||
{ matchStatus = 200 }
|
||||
|
||||
it "should update a char column with length" $
|
||||
request methodPatch "/bitchar_with_length?bit=eq.00000"
|
||||
[("Prefer", "return=representation")]
|
||||
[json|{"char": "zzzyy"}|]
|
||||
`shouldRespondWith` [json|[{ "bit": "00000", "char": "zzzyy" }]|]
|
||||
{ matchStatus = 200 }
|
||||
|
||||
context "tables with self reference foreign keys" $ do
|
||||
context "embeds children after update" $ do
|
||||
it "without filters" $
|
||||
|
||||
Vendored
+4
@@ -849,3 +849,7 @@ INSERT INTO datarep_todos VALUES (4, 'Opus Magnum', NULL, NULL);
|
||||
TRUNCATE TABLE datarep_next_two_todos CASCADE;
|
||||
INSERT INTO datarep_next_two_todos VALUES (1, 2, 3, 'school related');
|
||||
INSERT INTO datarep_next_two_todos VALUES (2, 1, 3, 'do these first');
|
||||
|
||||
TRUNCATE TABLE bitchar_with_length CASCADE;
|
||||
INSERT INTO bitchar_with_length(bit, char) VALUES ('00000', 'aaaaa');
|
||||
INSERT INTO bitchar_with_length(bit, char) VALUES ('11111', 'bbbbb');
|
||||
|
||||
Vendored
+6
@@ -3302,3 +3302,9 @@ create table bets (
|
||||
|
||||
create index bets_data_json on bets ((data_json ->>'contractId'));
|
||||
create index bets_data_jsonb on bets ((data_jsonb ->>'contractId'));
|
||||
|
||||
-- https://github.com/PostgREST/postgrest/issues/2861
|
||||
CREATE TABLE bitchar_with_length (
|
||||
bit bit(5),
|
||||
char char(5)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user