Repository navigation
Say which column default is invalid when creating a table fails - #9013
Conversation
A numeric default that parseInt or parseFloat can't read is now rejected up front with a 400 that names the column and the value, instead of reaching Postgres as NaN or Infinity and failing with an unrelated error. A date default Postgres rejects is matched back to its column from the quoted value in the error, so it gets the same 400. Defaults that work today are left alone.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9013 +/- ##
==========================================
+ Coverage 79.50% 79.54% +0.03%
==========================================
Files 475 475
Lines 26052 26076 +24
Branches 6942 6950 +8
==========================================
+ Hits 20712 20741 +29
+ Misses 5340 5335 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
andypalmi
left a comment
There was a problem hiding this comment.
-
Small edge in
findInvalidNumericDefault: a very large bigint default like99999999999999999999999passes the check, becauseparseIntreturns1e+23. The driver then writesDEFAULT 1e+23and Postgres rejects it as out of range, so the user still gets the bare "Failed to create table". Would it make sense to also reject values that aren't safe integers (Number.isSafeInteger)? Anything that works today would keep working. -
Question on
findInvalidDateDefault: it matches on the quoted value, so if two date columns share the same bad default, the message names the first one. Is that fine for now, since the user fixes it and retries, or worth naming both?
parseInt rounds a large bigint default into a value Postgres stores without complaint, so the table gets created and every insert that relies on the default then fails with bigint out of range. Such defaults now get the same 400 naming the column and value, before the driver runs. Values that only lose precision still create the table as they do today.
|
Good catch on the big bigints, thanks. It turned out a bit worse than expected: I tried it on Postgres and I went with a range check instead of On the two date columns sharing a bad default, I think naming the first is fine for now. Postgres stops at the first failure anyway, so with different bad values the user already fixes them one at a time, and with the same value the second one gets named on the retry. |
|
Creating an FF Tables table with a default that doesn't fit its column type failed with a bare "Failed to create table", so there was no way to tell which column or value to fix. Dates like
not-a-datefailed in Postgres with a message that names the value but not the column. Numbers thatparseIntorparseFloatcan't read went into the SQL asNaNorInfinityand failed with an unrelated "cannot use column reference in DEFAULT expression".The create-table route now returns a 400
invalid_column_defaultnaming the column and value, e.g.Invalid default value "not-a-date" for date column "created". Bad numeric defaults are caught before the driver runs. A date Postgres rejects is matched back to its column from the quoted value in the error, since the route can't tell up front which of the many date formats Postgres accepts. Anything that works today still does (today,01/02/2026, a bigint of12abc), and any other failure keeps the generic 500. The UI and the MCP tool both go through this route, so they pick up the message without changes.Checked against the local Postgres through the running forge: bad dates, out of range dates, a bad bigint and an
Infinityreal all come back as the new 400, and the defaults above still create tables. In the Create Table drawer the toast now shows the column and value. Route tests cover both paths and the generic fallback.Closes #8933