You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's consider blog posts as an example. In order to enable full text search on post body new column bodyIndexCol is created :
ALTER TABLE posts
ADD COLUMN body_index_col tsvector
GENERATED ALWAYS AS (to_tsvector('english', coalesce(body, ''))) STORED;
-- creating GIN index skipped due to irrelevance
After migration the Post constructor is extended with new bodyIndexCol as expected:
data Post' = Post
{ id :: (Id' "posts")
, title :: Text
, body :: Text
, bodyIndexCol :: (Maybe TSVector)
, meta :: MetaBag
} deriving (Eq, Show)
Now either creating new or updating any existing post crashes with error:
ConversionFailed
{ errSQLType = "3 values: [\"uuid\",\"text\",\"text\"]"
, errSQLTableOid = Nothing
, errSQLField = ""
, errHaskellType = "at least 4 slots in target type"
, errMessage = "mismatch between number of columns to convert and number in target type"
}
If we look into generated CanCreate instance for Post type:
instance CanCreate Post where
...
create model = do
List.head <$> sqlQuery "INSERT INTO posts (id, title, body) VALUES (?, ?, ?) RETURNING id, title, body" ((fieldWithDefault #id model, model.title, model.body))
...
we see that RETURNING clause of generated SQL insert statement contains only writeable fields (without new bodyIndexCol column) so Post constructor cannot be satisfied and leads to above error.
From db level new post was created indeed. Similar problem with createMany and update.
The text was updated successfully, but these errors were encountered:
Let's consider blog posts as an example. In order to enable full text search on post body new column
bodyIndexCol
is created :After migration the
Post
constructor is extended with newbodyIndexCol
as expected:Now either creating new or updating any existing post crashes with error:
If we look into generated
CanCreate
instance forPost
type:we see that
RETURNING
clause of generated SQL insert statement contains only writeable fields (without newbodyIndexCol
column) soPost
constructor cannot be satisfied and leads to above error.From db level new post was created indeed. Similar problem with
createMany
andupdate
.The text was updated successfully, but these errors were encountered: