Kallo
Kallo
DTDrizzle Team
Created by Kallo on 10/8/2023 in #help
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
2 replies