-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
78 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -2709,6 +2709,14 @@ describe Marten::DB::Query::Set do | |
end | ||
end | ||
|
||
describe "#to_sql" do | ||
it "produces the output of the query SQL representation" do | ||
qs = Marten::DB::Query::Set(Tag).new.filter(name: "ruby") | ||
|
||
qs.to_sql.should eq qs.query.to_sql | ||
end | ||
end | ||
|
||
describe "#update" do | ||
it "allows to update the records matching a given queryset with values specified as keyword arguments" do | ||
user_1 = TestUser.create!(username: "abc", email: "[email protected]", first_name: "John", last_name: "Doe") | ||
|
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 |
---|---|---|
|
@@ -2198,6 +2198,33 @@ describe Marten::DB::Query::SQL::Query do | |
end | ||
end | ||
|
||
describe "#to_sql" do | ||
it "produces the expected output" do | ||
query = Marten::DB::Query::SQL::Query(Tag).new | ||
query.add_query_node(Marten::DB::Query::Node.new(name__startswith: "r")) | ||
|
||
for_mysql do | ||
query.to_sql.should eq( | ||
"SELECT app_tag.id, app_tag.name, app_tag.is_active " \ | ||
"FROM `app_tag` WHERE app_tag.name LIKE BINARY ? LIMIT 18446744073709551615" | ||
) | ||
end | ||
|
||
for_postgresql do | ||
query.to_sql.should eq( | ||
"SELECT app_tag.id, app_tag.name, app_tag.is_active FROM \"app_tag\" WHERE app_tag.name LIKE $1" | ||
) | ||
end | ||
|
||
for_sqlite do | ||
query.to_sql.should eq( | ||
"SELECT app_tag.id, app_tag.name, app_tag.is_active " \ | ||
"FROM \"app_tag\" WHERE app_tag.name LIKE ? ESCAPE '\\' LIMIT -1" | ||
) | ||
end | ||
end | ||
end | ||
|
||
describe "#update_with" do | ||
it "allows to update the records matching a given query and returns the number of affected rows" do | ||
user_1 = TestUser.create!(username: "abc", email: "[email protected]", first_name: "John", last_name: "Doe") | ||
|
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