-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for V ORM #198
Open
daniel-le97
wants to merge
5
commits into
elliotchance:main
Choose a base branch
from
daniel-le97:vsql-orm-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
support for V ORM #198
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d4105ba
v orm implementation with standard query
daniel-le97 5851f45
orm: prefer db.prepare over db.query where possible, test now fully pass
daniel-le97 a082336
run make fmt
daniel-le97 7a9b776
chore: remove unnecessary comments, add more descriptive comments
daniel-le97 e988688
fix: uncomment orm_test.v
daniel-le97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,61 @@ | ||
import os | ||
import vsql | ||
import time | ||
|
||
// CHECK ./vsql/orm_test.v for more advanced usage | ||
|
||
fn main() { | ||
os.rm('test.vsql') or {} | ||
|
||
example() or { panic(err) } | ||
} | ||
|
||
// NOTE for some reason if we declare a @[primary] on a struct field, we can not do delete queries on the tables... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now fixed: #203 |
||
// https://github.com/elliotchance/vsql/issues/200 | ||
struct Product { | ||
id int //@[primary] | ||
product_name string @[sql_type: 'varchar(100)'] | ||
price f64 | ||
} | ||
|
||
fn example() ! { | ||
timer := time.new_stopwatch() | ||
mut db := vsql.open('test.vsql')! | ||
|
||
sql db { | ||
create table Product | ||
}! | ||
|
||
products := [ | ||
Product{1, 'Ice Cream', 5.99}, | ||
Product{2, 'Ham Sandwhich', 3.47}, | ||
Product{3, 'Bagel', 1.25}, | ||
] | ||
|
||
for product in products { | ||
sql db { | ||
insert product into Product | ||
} or { panic(err) } | ||
} | ||
sql db { | ||
update Product set product_name = 'Cereal' where id == 1 | ||
} or { panic(err) } | ||
|
||
prod_one := sql db { | ||
select from Product where id == 1 | ||
}! | ||
|
||
assert prod_one.len == 1 | ||
|
||
sql db { | ||
delete from Product where product_name == 'Cereal' | ||
} or { panic(err) } | ||
|
||
all := sql db { | ||
select from Product | ||
}! | ||
|
||
assert all.len == 2 | ||
|
||
println(timer.elapsed()) | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just adding a note here for me to add this to the docs.