Matlab's sqlwrite function doesn't play well with generated column in table

Viewed 14

In my Postgresql (v.14.5) database there is a generated 'date' column of type datetime that is generated from a timestamp column. If I omit this column when using Matlab's (v.R2021b) sqlwrite function, I get an error in line 155 of sqlwrite.m, which complains that the column before or after doesn't have the proper datetime type. This is odd behavior, but looking at the sqlwrite() code, it checks the data types from the connection object and I could imagine something fishy is happening there.

If instead I try to pass an NaT in the "date" value, it gets past line 155 of sqlwrite.m, but of course the database is unhappy, because I'm trying to write to a generated value, supposedly with a string "NaT" or something.

Even weirder is that everything works as long as I don't try to write to the 'date' column AND don't write to both of the columns on either side of it. If I only write to one of them (also omitting the 'date' column), regardless which, it works.

This seems like an edge case that wasn't checked or maybe there's a flag or something I need to set for generated columns. Anyone have any ideas?

0 Answers
Related