SQL_PARSE_ERROR with Turso + Drizzle

getting
SQL string could not be parsed: near MINUS, "None"
SQL string could not be parsed: near MINUS, "None"
when running a push in development with this schema:
import { sqliteTable, text, numeric, uniqueIndex, integer } from 'drizzle-orm/sqlite-core';
import { sql } from 'drizzle-orm';

export const blogPosts = sqliteTable(
'blog-posts',
{
id: integer('id').primaryKey().notNull(),
name: text('name').notNull(),
headline: text('headline').notNull(),
body: text('body').notNull(),
createdAt: integer('created_at')
.default(sql`(cast (unixepoch() as int))`)
.notNull()
},
(table) => {
return {
idUnique: uniqueIndex('blog-posts_id_unique').on(table.id)
};
}
);

export const testProducts = sqliteTable(
'test-products',
{
id: integer('id').primaryKey().notNull(),
name: text('name').notNull(),
strainType: text('strain_type').notNull(),
thcContent: text('thc_content').notNull(),
cbdContent: text('cbd_content').notNull(),
img: text('img').notNull(),
price: text('price').notNull(),
description: text('description').notNull(),
createdAt: integer('created_at')
.default(sql`(cast (unixepoch() as int))`)
.notNull(),
rating: integer('rating').default(0).notNull()
},
(table) => {
return {
idUnique: uniqueIndex('test-products_id_unique').on(table.id)
};
}
);
import { sqliteTable, text, numeric, uniqueIndex, integer } from 'drizzle-orm/sqlite-core';
import { sql } from 'drizzle-orm';

export const blogPosts = sqliteTable(
'blog-posts',
{
id: integer('id').primaryKey().notNull(),
name: text('name').notNull(),
headline: text('headline').notNull(),
body: text('body').notNull(),
createdAt: integer('created_at')
.default(sql`(cast (unixepoch() as int))`)
.notNull()
},
(table) => {
return {
idUnique: uniqueIndex('blog-posts_id_unique').on(table.id)
};
}
);

export const testProducts = sqliteTable(
'test-products',
{
id: integer('id').primaryKey().notNull(),
name: text('name').notNull(),
strainType: text('strain_type').notNull(),
thcContent: text('thc_content').notNull(),
cbdContent: text('cbd_content').notNull(),
img: text('img').notNull(),
price: text('price').notNull(),
description: text('description').notNull(),
createdAt: integer('created_at')
.default(sql`(cast (unixepoch() as int))`)
.notNull(),
rating: integer('rating').default(0).notNull()
},
(table) => {
return {
idUnique: uniqueIndex('test-products_id_unique').on(table.id)
};
}
);
I am adding the ratings column as an integer. Lets walk down the chain. When I add it as a new text column. It works. When I add it as an integer column with a default value and notNull, it gives me the warning that I am about to put null into a notNull column even though I have given it a default value, and then throws the error mentioned above. If I do it without the notNull, it just gives the error mentioned above. Working with SvelteKit btw
1 Reply
Kallo
KalloOP15mo ago
It may also be worth mentioning that I had an error that better-sqlite3 was missing when pushing, which is when this whole thing started. I uninstalled and reinstalled drizzle-kit and drizzle-orm to see if it would install better-sqlite3 as a peer dep again since I saw it in the lock file. It did not really work. I wound up just installing better-sqlite3 and that's when I started getting the current set of errors that I am describing above. Hopefully that sheds more light on the situation.
Want results from more Discord servers?
Add your server