-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
orm: support different foreign key types, not just an integer id (vla…
- Loading branch information
Showing
8 changed files
with
246 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
vlib/v/checker/tests/orm_fkey_has_pkey.vv:5:2: error: V ORM: a struct that has a field that holds an array must have a primary key | ||
3 | struct Person { | ||
4 | id int | ||
5 | child []Child [fkey: 'person_id'] | ||
| ~~~~~~~~~~~~~ | ||
6 | } | ||
7 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import db.sqlite | ||
|
||
struct Person { | ||
id int | ||
child []Child [fkey: 'person_id'] | ||
} | ||
|
||
struct Child { | ||
id int [primary; sql: serial] | ||
person_id int | ||
} | ||
|
||
fn main() { | ||
db := sqlite.connect(':memory:')! | ||
_ := sql db { | ||
select from Person | ||
}! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
vlib/v/checker/tests/orm_multiple_pkeys.vv:5:2: error: V ORM: a struct can only have one primary key | ||
3 | struct Person { | ||
4 | id int [primary] | ||
5 | name string [primary] | ||
| ~~~~~~~~~~~ | ||
6 | } | ||
7 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import db.sqlite | ||
|
||
struct Person { | ||
id int [primary] | ||
name string [primary] | ||
} | ||
|
||
fn main() { | ||
db := sqlite.connect(':memory:')! | ||
_ := sql db { | ||
select from Person | ||
}! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.