orm: fix inserting sequential values (id=0), in tables with an i64 primary field (#18791)

This commit is contained in:
Delyan Angelov 2023-07-05 23:25:22 +03:00 committed by GitHub
parent 7f8749afdd
commit aa61fcb3dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 3 deletions

View file

@ -287,3 +287,29 @@ fn test_orm_insert_with_multiple_child_elements() {
assert parent.notes[1].text == 'Second note'
assert parent.notes[2].text == 'Third note'
}
[table: 'customers']
struct Customer {
id i64 [primary; sql: serial]
name string
}
fn test_i64_primary_field_works_with_insertions_of_id_0() {
db := sqlite.connect(':memory:')!
sql db {
create table Customer
}!
for i in ['Bob', 'Charlie'] {
new_customer := Customer{
name: i
}
sql db {
insert new_customer into Customer
}!
}
users := sql db {
select from Customer
}!
assert users.len == 2
// println("${users}")
}