sqlite_orm icon indicating copy to clipboard operation
sqlite_orm copied to clipboard

IF EXISTS: Is it possible?

Open trevornagy opened this issue 1 year ago • 4 comments

How would I write the following using sqlite_orm?

DROP TRIGGER IF EXISTS trigger DROP TABLE IF EXISTS table

More specifically the IF EXISTS / IF NOT EXISTS part as I see drop_table / drop_trigger are part of the library. I see there is a table_exists(...) method, but nothing equivalent for triggers.

trevornagy avatar Jun 20 '24 11:06 trevornagy

I see it can be implemented in several ways:

  1. storage.drop_table_if_exists(...); - one more func
  2. storage.drop_table(if_exists(...)); - one more overload
  3. your option

@trevornagy do you have any API preference for this?

BTW IF NOT EXISTS makes no sense cause DROP TABLE my_table IF NOT EXISTS is ridiculous =)

fnc12 avatar Jun 21 '24 19:06 fnc12

I prefer option 2 as the api would be more consistent for triggers/tables.

trevornagy avatar Jun 21 '24 19:06 trevornagy

I was thinking a lot about which option to pick. So I'd like to stick with option 1 cause it is easier for newbies cause once you type storage.drop you see all the options. In the case of option 2 you will type storage.drop but how to specify if_exists may be not clear from the first sight. I hope you agree

fnc12 avatar Jun 23 '24 07:06 fnc12

I like the overload better Juan Dent Sent from my iPhoneOn 23 Jun 2024, at 1:36 AM, Yevgeniy Zakharov @.***> wrote: I was thinking a lot about which option to pick. So I'd like to stick with option 1 cause it is easier for newbies cause once you type storage.drop you see all the options. In the case of option 2 you will type storage.drop but how to specify if_exists may be not clear from the first sight. I hope you agree

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

juandent avatar Jun 23 '24 17:06 juandent

Hey @fnc12, just wondering if there was any progress on this issue?

trevornagy avatar Jul 09 '24 17:07 trevornagy

@trevornagy in progress

fnc12 avatar Jul 12 '24 20:07 fnc12

PR https://github.com/fnc12/sqlite_orm/pull/1333

fnc12 avatar Jul 13 '24 11:07 fnc12

@trevornagy done. Please check dev branch

fnc12 avatar Jul 15 '24 16:07 fnc12

Much appreciated, testing now!

trevornagy avatar Jul 15 '24 16:07 trevornagy