Skip to content

Introspect zero defaults on SingleStore numeric columns#5954

Open
greymoth-jp wants to merge 1 commit into
drizzle-team:mainfrom
greymoth-jp:fix-singlestore-introspect-zero-default
Open

Introspect zero defaults on SingleStore numeric columns#5954
greymoth-jp wants to merge 1 commit into
drizzle-team:mainfrom
greymoth-jp:fix-singlestore-introspect-zero-default

Conversation

@greymoth-jp

Copy link
Copy Markdown

Introspecting (drizzle-kit pull) a SingleStore smallint, mediumint, bigint, float, double or real column whose DEFAULT is 0 drops the default from the generated schema.

Each of those branches in introspect-singlestore.ts guards .default() with a plain truthy check on the default value:

out += defaultValue
  ? `.default(${mapColumnDefault(defaultValue, isExpression)})`
  : '';

0 is falsy, so it is treated as "no default" and the generated TypeScript loses it, even though the introspected snapshot stores the 0 correctly. A fresh pull then stops matching the database. The int and tinyint branches in the same file already guard with typeof defaultValue !== 'undefined'; this applies the same check to the remaining numeric branches.

This is the SingleStore counterpart of #5917 (MySQL float/double/real) and #5918 (MySQL smallint/mediumint/bigint) — the SingleStore introspector has the same branches with the same truthy guard.

I scoped the change to the numeric types covered by those two PRs and left boolean untouched. I didn't add a test because the introspect suite starts a SingleStore container, which I couldn't run locally; happy to mirror the tests from #5917/#5918 if you'd prefer one here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant