WhyDoThis
WhyDoThis
KKysely
Created by WhyDoThis on 9/10/2024 in #help
pg migration raw sql CREATE FUNCTION gets error: "TypeError: Cannot redefine property: then"
So took a bit of searching every possible previous issue/thread and finally stumbled across this answer from @koskimas in another thread last year: https://discord.com/channels/890118421587578920/1108366659707736154/1108386004232060938
You have two (or more) incompatible versions of Kysely and you are mixing parts of them.
In my case this somehow occurred from kysely v0.27.3 + kysely-ctl 0.8.7. Bumped to v.0.27.4 + 0.9.0 respectively fixed it.
4 replies
KKysely
Created by WhyDoThis on 9/5/2024 in #help
Updateable primary key question & .set() type safety
@TheMelonAssassin see one of the answers here: https://stackoverflow.com/q/69327990 and what Igal wrote about "satisfies" above.
13 replies
KKysely
Created by WhyDoThis on 9/5/2024 in #help
Updateable primary key question & .set() type safety
For future searchers what I doing for now is this:
type WithoutIdCol<T> = Omit<T, "id">; ... export type UserUpdate = Updateable<WithoutIdCol<UserTable>>;
Since its just one more generic wrapper I will leave it but if it grows beyond Id I would just make an Updateable wrapper that does it all. (I've gone this route versus on the column definition because for the table types I am using kysely-codegen and its one less thing to add to my manual modification list I have to do post re-generating) and in set:
... .set({id: 'blah'} satisfies UserUpdate) ...
which now properly TS errors. Thanks again Igal!
13 replies
KKysely
Created by WhyDoThis on 9/5/2024 in #help
Updateable primary key question & .set() type safety
@koskimas I think you misunderstood. I wasn't implying kysely should prevent it out of the box I am asking for those who want to modify so a certain column (like id) can not be passed in say on a patch object unintentionally that's based on the db types generated by kysely which would include it. I appreciate you reading + replying nonetheless.
13 replies
KKysely
Created by WhyDoThis on 9/5/2024 in #help
Updateable primary key question & .set() type safety
Thanks @Igal I'll check this out! You perfectly understood what I was asking thank you so much.
13 replies
KKysely
Created by WhyDoThis on 8/20/2024 in #help
What's the best way to use Pick with Selectable/Insertable/Updatable?
Actually I think this is environmental - I found there is a kysely sandbox and I couldn't repro there - it works perfect there in how I showed/you showed in the "better yet". I am going to close this and thanks again @koskimas
7 replies
KKysely
Created by WhyDoThis on 8/20/2024 in #help
What's the best way to use Pick with Selectable/Insertable/Updatable?
(Upon review though I did see in my OP one small mistake which is I accidently pasted the intentionally wrong function assignment line again instead of the error for the second example - I've corrected that bit now.)
7 replies
KKysely
Created by WhyDoThis on 8/20/2024 in #help
What's the best way to use Pick with Selectable/Insertable/Updatable?
Thanks for checking this out. Yup I definitely think you misunderstood. To recap, you can see in first screenshot I did what your "better yet" shows (the User type for it is in fact Selectable<UserTable> as can be seen in second screenshot and referenced in the OP "But if I try to Pick from a table schema wrapped in Selectable/Insertable/Updateable..."). When you said "my first example" you pasted not what I attempted but what I wrote in the OP that the pick type in my first example/your "better yet" shows in VS code to resolve to (when I hover over it). Of course that type would make no sense. I used the function assignment to clearly show it doesn't error on something it should. Second screenshot example was just to demonstrate it does in fact error if I reference directly from UserTable.
7 replies
KKysely
Created by WhyDoThis on 6/28/2024 in #help
defineConfig using --environment type issue with seedFolder
Thank you!!!
14 replies
KKysely
Created by WhyDoThis on 6/28/2024 in #help
defineConfig using --environment type issue with seedFolder
I will add it to the issue - thanks for taking a look
14 replies
KKysely
Created by WhyDoThis on 6/28/2024 in #help
defineConfig using --environment type issue with seedFolder
No description
14 replies
KKysely
Created by WhyDoThis on 6/28/2024 in #help
defineConfig using --environment type issue with seedFolder
@Igal sorry one more thing - you think I should add to it that it also only lets you use the environment name strings found in c12's C12InputConfig interface? Reason I ask is kysely-ctl's src/arguments/environment.mts has valueHint of 'prod | dev | test | ...' but you actually can't use those abbreviations for production and development without other typescript compilation error.
Object literal may only specify known properties, and '$dev' does not exist in type '(C12InputConfig<KyselyCTLConfig<KyselyDialect>, ConfigLayerMeta> & KyselyCTLConfigBase & { ...; } & { ...; } & { ...; }) | ... 7 more ... | (C12InputConfig<...> & ... 3 more ... & { ...; })'.ts(2353)
14 replies
KKysely
Created by WhyDoThis on 6/28/2024 in #help
defineConfig using --environment type issue with seedFolder
53 in ctl
14 replies
KKysely
Created by WhyDoThis on 6/28/2024 in #help
defineConfig using --environment type issue with seedFolder
Thanks @Igal and no worries at all - let me know if you'd like me to open an issue for tracking purposes
14 replies
KKysely
Created by WhyDoThis on 6/27/2024 in #help
Is there an easy tool to convert my existing knex migrations to kysely migrations?
Thank you!
25 replies
KKysely
Created by WhyDoThis on 6/27/2024 in #help
Is there an easy tool to convert my existing knex migrations to kysely migrations?
@Igal I finally got done mapping everything over and went to dry run - I throw at the end of the "up" but how do I see the sql it was going to use to make the changes? Or did I understand your recommendation incorrectly on that part?
25 replies
KKysely
Created by WhyDoThis on 6/27/2024 in #help
Is there an easy tool to convert my existing knex migrations to kysely migrations?
interesting thanks
25 replies
KKysely
Created by WhyDoThis on 6/27/2024 in #help
Is there an easy tool to convert my existing knex migrations to kysely migrations?
You are too humble haha - sorry to derail the original point of this thread but is there a way to dry run the migration that you know of? My current thought is the only way to test is by wiping the DB completely (or point to a different one) and re-backing it up to compare the schema of the rewritten kysely migration to the original schema created by the knex migration. I've always longed for something like Entity Framework how it can compare and show diffs before executing.
25 replies
KKysely
Created by WhyDoThis on 6/27/2024 in #help
Is there an easy tool to convert my existing knex migrations to kysely migrations?
For sure - I appreciate you and the teams hard work on it!
25 replies