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
functions in index expression must be marked IMMUTABLE
Index example: CREATE INDEX mt_doc_targetwithdates_idx_local_date ON noda_time_acceptance.mt_doc_targetwithdates USING btree ((CAST(data ->> 'LocalDate' as date)));
I think it is going to be a bit tricky to deal with. This will require a wrapper function for each of the mapped NodaTime Postgres types which does the cast and is marked immutable to circumvent functions in index expression must be marked IMMUTABLE issue:
CREATE
OR REPLACE FUNCTION mt_to_date_immutable(data varchar) RETURNS dateAS
$$
BEGIN
return CAST(data asdate);
END;
$$
LANGUAGE plpgsql immutable;
and then while creating index, you will use the above function instead of the cast as below:
CREATEINDEXmt_doc_targetwithdates_idx_local_dateONnoda_time_acceptance.mt_doc_targetwithdates
USING btree (mt_to_date_immutable(data ->>'LocalDate'));
Possibly an alternative and easier approach is to create a duplicate field with relevant type and create an index on it. This won't require any changes on Marten as such. You could try this and confirm. If this works well then we will add docs for the same.
Creating a duplicated field works, but if NodaTime is the preferred way of working with date and time (according to Npgsql) I think this should be supported.
With duplicated field you also get a potential unused index if you need a multicolumn index.
Indexing Node Time types fails with
Index example:
CREATE INDEX mt_doc_targetwithdates_idx_local_date ON noda_time_acceptance.mt_doc_targetwithdates USING btree ((CAST(data ->> 'LocalDate' as date)));
Added failing test here #2413
The text was updated successfully, but these errors were encountered: