SimpleSQLite icon indicating copy to clipboard operation
SimpleSQLite copied to clipboard

Foreign Key

Open soraxas opened this issue 2 years ago • 2 comments

Thanks for this repo!

Does SimpleSQLite supports foreign key (with ORM) by referencing another table?

For example:

class EmailAddress(Model):
    id = Integer(primary_key=True)
    address = Text(not_null=True, unique=True)

class Email(Model):
    id = Integer(primary_key=True)
    content= Text()
    from_addr = Email()  # This?
    to_addr = Email()  # And this?

Moreover, if so, can we create the corresponding foreignkey entry if it doesn't already exists?

Email.insert(
  Email(
    content="Hello!", 
    from_addr=EmailAddress(...), 
    to_addr=EmailAddress(...),
  )
)

soraxas avatar Nov 29 '23 12:11 soraxas

@soraxas Unfortunately, SimpleSQLite does not support foreign keys for ORM for now. I will consider future enhancements.

thombashi avatar Dec 03 '23 04:12 thombashi

I see! Anything that I can help with it?

soraxas avatar Dec 04 '23 09:12 soraxas