Open fn3x opened 3 months ago
I can confirm this happens with 0.32.0. If you add .notNull()
to the column declaration the error disappears
Was testing out drizzle for the first time today and ran into this issue on a fresh install trying to figure out what was wrong. Downgraded to 0.31.4 based on @marko1010 's comment and it resolved the type issues for now.
Can confirm am also getting this issue with node-pg on 0.32.0
update drizzle-orm
to v0.32.1
can confirm that it's already solved
can safely remove
- "resolutions": {
- "drizzle-orm": "0.31.4"
- }
from my package.json
starts from now
kudos drizzle team π
I have still this issue on drizzle-orm@0.32.1
and drizzle-kit@0.23.0
:<
I have still this issue on
drizzle-orm@0.32.1
anddrizzle-kit@0.23.0
:<
Yep, I have this issue still on drizzle-orm@0.32.1
I have still this issue on
drizzle-orm@0.32.1
anddrizzle-kit@0.23.0
:<Yep, I have this issue still on
drizzle-orm@0.32.1
ya, i experienced this again, and i don't know why
end up to add these again to my package.json.
+ "resolutions": {
+ "drizzle-orm": "0.31.4"
+ }
I am also experiencing this issue on 0.32.1
It looks like now drizzle-orm@0.32.0+
requires in tsconfig.json
set strictNullChecks
and strict
to true
.
:>> when they fix it :????
"drizzle-kit": "^0.24.0",
"drizzle-orm": "^0.33.0",
notNull
to table column:
A little unrelated but getting the same error when doing a nested query; isVerified: true
was giving me the error.
Adding the strict
and strictNullChecks
didn't work for me. I ended just casting it to any
like:
db.query.products.findMany({
where: ...,
with: {
user: {
isVerified: true, // This is where I was getting the error
columns: { password: false }
...
} as any
}
})
Had the same issue with:
"drizzle-kit": "^0.24.0", "drizzle-orm": "^0.33.0",
Tested following fixes in this thread:
Adding
notNull
to table column:
- Fixes the error, but then as expected I'm getting errors where I'm not using the column.
- Resolutions does not do anything for me.
- Adding strict null checks fixed it for me.
Update: it did fix! thanks!
Sadly, it didn't fix it for me:
const insertId = await this.db.insert(players).values({
userId: playerData.uid,
firstname: playerData.firstname,
lastname: playerData.lastname,
nickname: playerData.nickname,
language: playerData.language,
}).then(res => res[0].insertId)
typescript: No overload matches this call. β
β Overload 2 of 2, '(values: { partnerId: number | SQL
So the issue is still relevant but @Ymirke found out a workaround
Same issue here. Adding strict null checks is not an option for many existing code bases (although I agree its better to fix those potential type errors, but there'll be many code bases out there that won't be able to accommodate that). In my case, I needed to
^0.30.0
^0.21.0
1.0.7
Are there plans to tackle this issue?
It looks like now
drizzle-orm@0.32.0+
requires intsconfig.json
setstrictNullChecks
andstrict
totrue
.
insert into compilerOptions works for me, thanks!
But other things started to bother me in TypeScript.
Now null strings are no longer allowed without defining string | null
This is really annoying...
I have the issue with "drizzle-kit": "^0.25.0", "drizzle-orm": "^0.34.1",
even with "strictNullChecks": true, "strict": true,
π
It looks like now
drizzle-orm@0.32.0+
requires intsconfig.json
setstrictNullChecks
andstrict
totrue
.
This fixed the issue for me. Could you please elaborate why that is related? I was trying to update field of a user table but TypeScript complained about most attributes that I tried to edit. How is this related?
I was getting the same error. And even after adding the tsconfig changes, the Nest application was failing at build. I assumed that maybe... when the update query is being ran for a field, it is not able to determine if the row actually exists in the Database or not. Hence there is an SQLUnknown in the the type def. I don't know how accurate i am with this but it seems to have worked :
`async addBalance(amount : number, id : string) { try { if(amount < 0) { throw new HttpException('Invalid amount', HttpStatus.BAD_REQUEST); }
const userAccount = await db.query.AccountTable.findFirst({
where: eq(AccountTable.userId, id)
});
if(!userAccount) {
throw new HttpException('Account not Found.', HttpStatus.BAD_REQUEST);
}
userAccount.balance += amount;
await db.update(AccountTable).set(userAccount).where(eq(AccountTable.userId, id));
// This line was giving me the same problem.
// await db.update(AccountTable).set({ balance: amount }).where(eq(AccountTable.userId, id));
return { message : "Successfully added balance" };
} catch (error) {
if (error instanceof HttpException) {
throw error;
}
throw new HttpException(
'Failed to register user',
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
} `
Though I do feel this adds one extra query. But this seemed to be the only solution I could devise. Hope it helps someone.
Also, After adding this I could turn back the tsconfig changes, so less headache while developing yay.
"drizzle-orm": "^0.33.0"
hello, I have this config
import { defineConfig } from "drizzle-kit";
export default defineConfig({
schema:"./src/db/schema.ts",
out: "./src/db/migrations",
dialect: "sqlite",
driver: "d1-http",
strictNullChecks : true,
strict: true,
dbCredentials: {
url: "file:./src/db/sqlite.db",
},
});
And I'm having the error in the url inside of the dbCredentials :
Object literal may only specify known properties, and 'url' does not exist in type '{ accountId: string; databaseId: string; token: string; }'.ts(2353) (property) url: string
Any idea on what can be wrong ??
Thank you in advance,
Seems like you are getting this error because of a bad config, though everything does look right right to me. Drizzle is always updating and changing these things so I suggest you to take a good look through docs : https://orm.drizzle.team/docs/get-started/sqlite-new
Thank you, Actually I get this path error but I can run the drizzle-kit generate command, it creates the migrations folder with content.
However, if I try to use the command migrate, or push, I get this error :
$ npx drizzle-kit migrate No config path provided, using default 'drizzle.config.ts' Reading config file 'C:\Users\chicn\OneDrive\Ambiente de Trabalho\Personal code Projects 2024\code 2024\Node18\receitas\drizzle.config.ts' Error Please provide required params for D1 HTTP driver: [x] accountId: undefined [x] databaseId: undefined [x] token: undefined
Any idea on how to solve this?
I'm just working with an sqlite database file with no credentials on it yet.
It seems that the problem was that I was defining a driver, when I'm actually working locally. Removing this prop solved the issue of url does not exist in type, and the params for D1 HTTP driver missing. The only warning that persists it seems to be the path. But it seems it doesn't have a negative effect on drizzle commands.
Thank you for the reply !
Thank, I'm loving working with Drizzle-kit until now. I would just love to know if there is a way to remove the ascii chars that appear in the middle of the messages for color. I've tried to deactivate them using the NO_COLOR variable, it didn't work, and trying other terminals such as powershell. Maybe there is another way, but I didn't find it yet.
example : Drizzle Studio is up and running on β[34mhttps://local.drizzle.studioβ[39m
Thank tou for the good work !
What version of
drizzle-orm
are you using?0.32.0
What version of
drizzle-kit
are you using?0.23.0
Describe the Bug
I bumped the versions of drizzle-orm 0.31.4 -> 0.32.0 and drizzle-kit 0.22.8 -> 0.23.0. After that my project stopped from building because some of the columns are not being recognized by the type system. I provided the error log, table definition and code that uses it below.
TS compiler error log:
Table definition in schema.ts:
Usage of table to perform queries:
Expected behavior
All specified columns being recognized by the type system on writing queries
Environment & setup
Node.js v20.12.2 drizzle-kit v0.32.0 drizzle-orm v0.23.0