sequel 3.21.0 → 3.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +294 -0
- data/README.rdoc +20 -6
- data/Rakefile +20 -15
- data/doc/association_basics.rdoc +210 -43
- data/doc/dataset_basics.rdoc +4 -4
- data/doc/mass_assignment.rdoc +54 -0
- data/doc/migration.rdoc +15 -538
- data/doc/model_hooks.rdoc +64 -27
- data/doc/opening_databases.rdoc +37 -10
- data/doc/prepared_statements.rdoc +16 -10
- data/doc/reflection.rdoc +8 -2
- data/doc/release_notes/3.22.0.txt +39 -0
- data/doc/release_notes/3.23.0.txt +172 -0
- data/doc/release_notes/3.24.0.txt +420 -0
- data/doc/release_notes/3.25.0.txt +88 -0
- data/doc/release_notes/3.26.0.txt +88 -0
- data/doc/release_notes/3.27.0.txt +82 -0
- data/doc/release_notes/3.28.0.txt +304 -0
- data/doc/schema_modification.rdoc +547 -0
- data/doc/testing.rdoc +106 -0
- data/doc/transactions.rdoc +97 -0
- data/doc/virtual_rows.rdoc +2 -2
- data/lib/sequel/adapters/ado.rb +12 -1
- data/lib/sequel/adapters/amalgalite.rb +4 -0
- data/lib/sequel/adapters/db2.rb +95 -58
- data/lib/sequel/adapters/do.rb +12 -0
- data/lib/sequel/adapters/firebird.rb +25 -203
- data/lib/sequel/adapters/ibmdb.rb +440 -0
- data/lib/sequel/adapters/informix.rb +4 -19
- data/lib/sequel/adapters/jdbc/as400.rb +0 -7
- data/lib/sequel/adapters/jdbc/db2.rb +49 -0
- data/lib/sequel/adapters/jdbc/firebird.rb +34 -0
- data/lib/sequel/adapters/jdbc/h2.rb +16 -5
- data/lib/sequel/adapters/jdbc/informix.rb +31 -0
- data/lib/sequel/adapters/jdbc/jtds.rb +34 -0
- data/lib/sequel/adapters/jdbc/mssql.rb +0 -32
- data/lib/sequel/adapters/jdbc/mysql.rb +9 -0
- data/lib/sequel/adapters/jdbc/oracle.rb +2 -27
- data/lib/sequel/adapters/jdbc/postgresql.rb +6 -0
- data/lib/sequel/adapters/jdbc/sqlserver.rb +46 -0
- data/lib/sequel/adapters/jdbc/transactions.rb +34 -0
- data/lib/sequel/adapters/jdbc.rb +62 -29
- data/lib/sequel/adapters/mysql.rb +22 -139
- data/lib/sequel/adapters/mysql2.rb +9 -14
- data/lib/sequel/adapters/odbc/db2.rb +21 -0
- data/lib/sequel/adapters/odbc.rb +15 -3
- data/lib/sequel/adapters/oracle.rb +17 -1
- data/lib/sequel/adapters/postgres.rb +111 -16
- data/lib/sequel/adapters/shared/access.rb +21 -0
- data/lib/sequel/adapters/shared/db2.rb +290 -0
- data/lib/sequel/adapters/shared/firebird.rb +214 -0
- data/lib/sequel/adapters/shared/informix.rb +45 -0
- data/lib/sequel/adapters/shared/mssql.rb +85 -47
- data/lib/sequel/adapters/shared/mysql.rb +50 -7
- data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +143 -0
- data/lib/sequel/adapters/shared/oracle.rb +0 -4
- data/lib/sequel/adapters/shared/postgres.rb +75 -43
- data/lib/sequel/adapters/shared/sqlite.rb +56 -8
- data/lib/sequel/adapters/sqlite.rb +12 -11
- data/lib/sequel/adapters/swift/mysql.rb +9 -0
- data/lib/sequel/adapters/tinytds.rb +139 -7
- data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +55 -0
- data/lib/sequel/ast_transformer.rb +190 -0
- data/lib/sequel/connection_pool/threaded.rb +3 -2
- data/lib/sequel/connection_pool.rb +1 -1
- data/lib/sequel/core.rb +6 -5
- data/lib/sequel/database/connecting.rb +5 -5
- data/lib/sequel/database/dataset.rb +1 -1
- data/lib/sequel/database/dataset_defaults.rb +1 -1
- data/lib/sequel/database/logging.rb +1 -1
- data/lib/sequel/database/misc.rb +38 -17
- data/lib/sequel/database/query.rb +50 -19
- data/lib/sequel/database/schema_generator.rb +8 -5
- data/lib/sequel/database/schema_methods.rb +52 -27
- data/lib/sequel/dataset/actions.rb +167 -48
- data/lib/sequel/dataset/features.rb +57 -8
- data/lib/sequel/dataset/graph.rb +1 -1
- data/lib/sequel/dataset/misc.rb +39 -20
- data/lib/sequel/dataset/mutation.rb +3 -3
- data/lib/sequel/dataset/prepared_statements.rb +29 -14
- data/lib/sequel/dataset/query.rb +182 -32
- data/lib/sequel/dataset/sql.rb +31 -58
- data/lib/sequel/dataset.rb +8 -0
- data/lib/sequel/exceptions.rb +4 -0
- data/lib/sequel/extensions/columns_introspection.rb +61 -0
- data/lib/sequel/extensions/migration.rb +6 -4
- data/lib/sequel/extensions/to_dot.rb +95 -83
- data/lib/sequel/model/associations.rb +893 -309
- data/lib/sequel/model/base.rb +302 -105
- data/lib/sequel/model/errors.rb +1 -1
- data/lib/sequel/model/exceptions.rb +5 -1
- data/lib/sequel/model.rb +13 -7
- data/lib/sequel/plugins/association_pks.rb +22 -4
- data/lib/sequel/plugins/defaults_setter.rb +58 -0
- data/lib/sequel/plugins/identity_map.rb +113 -6
- data/lib/sequel/plugins/many_through_many.rb +67 -5
- data/lib/sequel/plugins/prepared_statements.rb +140 -0
- data/lib/sequel/plugins/prepared_statements_associations.rb +84 -0
- data/lib/sequel/plugins/prepared_statements_safe.rb +82 -0
- data/lib/sequel/plugins/prepared_statements_with_pk.rb +59 -0
- data/lib/sequel/plugins/serialization_modification_detection.rb +51 -0
- data/lib/sequel/plugins/sharding.rb +12 -20
- data/lib/sequel/plugins/single_table_inheritance.rb +2 -0
- data/lib/sequel/plugins/update_primary_key.rb +1 -1
- data/lib/sequel/plugins/xml_serializer.rb +3 -3
- data/lib/sequel/sql.rb +107 -51
- data/lib/sequel/timezones.rb +12 -3
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/db2_spec.rb +146 -0
- data/spec/adapters/mssql_spec.rb +36 -0
- data/spec/adapters/mysql_spec.rb +36 -19
- data/spec/adapters/postgres_spec.rb +115 -28
- data/spec/adapters/spec_helper.rb +6 -0
- data/spec/adapters/sqlite_spec.rb +11 -0
- data/spec/core/connection_pool_spec.rb +62 -77
- data/spec/core/database_spec.rb +244 -287
- data/spec/core/dataset_spec.rb +383 -34
- data/spec/core/expression_filters_spec.rb +159 -41
- data/spec/core/schema_spec.rb +326 -3
- data/spec/core/spec_helper.rb +45 -0
- data/spec/extensions/association_pks_spec.rb +38 -0
- data/spec/extensions/columns_introspection_spec.rb +91 -0
- data/spec/extensions/defaults_setter_spec.rb +64 -0
- data/spec/extensions/identity_map_spec.rb +162 -0
- data/spec/extensions/many_through_many_spec.rb +195 -20
- data/spec/extensions/migration_spec.rb +17 -17
- data/spec/extensions/nested_attributes_spec.rb +1 -0
- data/spec/extensions/prepared_statements_associations_spec.rb +126 -0
- data/spec/extensions/prepared_statements_safe_spec.rb +79 -0
- data/spec/extensions/prepared_statements_spec.rb +72 -0
- data/spec/extensions/prepared_statements_with_pk_spec.rb +38 -0
- data/spec/extensions/schema_dumper_spec.rb +2 -2
- data/spec/extensions/schema_spec.rb +12 -20
- data/spec/extensions/serialization_modification_detection_spec.rb +36 -0
- data/spec/extensions/single_table_inheritance_spec.rb +11 -0
- data/spec/extensions/spec_helper.rb +3 -1
- data/spec/extensions/to_dot_spec.rb +3 -5
- data/spec/extensions/xml_serializer_spec.rb +16 -4
- data/spec/integration/associations_test.rb +405 -15
- data/spec/integration/database_test.rb +4 -2
- data/spec/integration/dataset_test.rb +240 -20
- data/spec/integration/plugin_test.rb +142 -5
- data/spec/integration/prepared_statement_test.rb +174 -95
- data/spec/integration/schema_test.rb +128 -16
- data/spec/integration/spec_helper.rb +15 -0
- data/spec/integration/transaction_test.rb +40 -0
- data/spec/integration/type_test.rb +16 -2
- data/spec/model/association_reflection_spec.rb +91 -0
- data/spec/model/associations_spec.rb +476 -5
- data/spec/model/base_spec.rb +91 -1
- data/spec/model/eager_loading_spec.rb +519 -31
- data/spec/model/hooks_spec.rb +161 -0
- data/spec/model/model_spec.rb +89 -2
- data/spec/model/plugins_spec.rb +17 -0
- data/spec/model/record_spec.rb +184 -12
- data/spec/model/spec_helper.rb +5 -0
- data/spec/model/validations_spec.rb +11 -0
- metadata +85 -34
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
|
|
2
|
+
|
|
3
|
+
describe "prepared_statements_with_pk plugin" do
|
|
4
|
+
before do
|
|
5
|
+
@c = Class.new(Sequel::Model(:people))
|
|
6
|
+
@c.columns :id, :name, :i
|
|
7
|
+
@ds = ds = @c.dataset
|
|
8
|
+
def ds.fetch_rows(sql)
|
|
9
|
+
db << {:server=>@opts[:server] || :read_only}.merge(opts)[:server]
|
|
10
|
+
super{|h|}
|
|
11
|
+
yield(:id=>1, :name=>'foo', :i=>2)
|
|
12
|
+
end
|
|
13
|
+
@c.plugin :prepared_statements_with_pk
|
|
14
|
+
@p = @c.load(:id=>1, :name=>'foo', :i=>2)
|
|
15
|
+
@c.db.execute 'foo'
|
|
16
|
+
@sqls = @c.db.sqls
|
|
17
|
+
@sqls.clear
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
specify "should load the prepared_statements plugin" do
|
|
21
|
+
@c.plugins.should include(Sequel::Plugins::PreparedStatements)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
specify "should correctly lookup by primary key from dataset" do
|
|
25
|
+
@c.dataset.filter(:name=>'foo')[1].should == @p
|
|
26
|
+
@sqls.should == [:read_only, "SELECT * FROM people WHERE ((name = 'foo') AND (people.id = 1)) LIMIT 1"]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
specify "should still work correctly if there are multiple conflicting variables" do
|
|
30
|
+
@c.dataset.filter(:name=>'foo').or(:name=>'bar')[1].should == @p
|
|
31
|
+
@sqls.should == [:read_only, "SELECT * FROM people WHERE (((name = 'foo') OR (name = 'bar')) AND (people.id = 1)) LIMIT 1"]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
specify "should still work correctly if the primary key is used elsewhere in the query" do
|
|
35
|
+
@c.dataset.filter{id > 2}[1].should == @p
|
|
36
|
+
@sqls.should == [:read_only, "SELECT * FROM people WHERE ((id > 2) AND (people.id = 1)) LIMIT 1"]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -263,8 +263,8 @@ END_MIG
|
|
|
263
263
|
s.each{|_, c| c[:ruby_default] = column_schema_to_ruby_default(c[:default], c[:type])}
|
|
264
264
|
s
|
|
265
265
|
end
|
|
266
|
-
@d.dump_table_schema(:t4).gsub(/[+-]\d\d:\d\d"\)/, '")').should == "create_table(:t4) do\n TrueClass :c1, :default=>false\n String :c2, :default=>\"blah\"\n Integer :c3, :default=>-1\n Float :c4, :default=>1.0\n BigDecimal :c5, :default=>BigDecimal.new(\"0.1005E3\")\n File :c6, :default=>Sequel::SQL::Blob.new(\"blah\")\n Date :c7, :default=>Date.parse(\"2008-10-29\")\n DateTime :c8, :default=>DateTime.parse(\"2008-10-29T10:20:30\")\n Time :c9, :default=>
|
|
267
|
-
@d.dump_table_schema(:t4, :same_db=>true).gsub(/[+-]\d\d:\d\d"\)/, '")').should == "create_table(:t4) do\n column :c1, \"boolean\", :default=>false\n column :c2, \"varchar\", :default=>\"blah\"\n column :c3, \"integer\", :default=>-1\n column :c4, \"float\", :default=>1.0\n column :c5, \"decimal\", :default=>BigDecimal.new(\"0.1005E3\")\n column :c6, \"blob\", :default=>Sequel::SQL::Blob.new(\"blah\")\n column :c7, \"date\", :default=>Date.parse(\"2008-10-29\")\n column :c8, \"datetime\", :default=>DateTime.parse(\"2008-10-29T10:20:30\")\n column :c9, \"time\", :default=>
|
|
266
|
+
@d.dump_table_schema(:t4).gsub(/[+-]\d\d:\d\d"\)/, '")').should == "create_table(:t4) do\n TrueClass :c1, :default=>false\n String :c2, :default=>\"blah\"\n Integer :c3, :default=>-1\n Float :c4, :default=>1.0\n BigDecimal :c5, :default=>BigDecimal.new(\"0.1005E3\")\n File :c6, :default=>Sequel::SQL::Blob.new(\"blah\")\n Date :c7, :default=>Date.parse(\"2008-10-29\")\n DateTime :c8, :default=>DateTime.parse(\"2008-10-29T10:20:30\")\n Time :c9, :default=>Sequel::SQLTime.parse(\"10:20:30\"), :only_time=>true\n String :c10\nend"
|
|
267
|
+
@d.dump_table_schema(:t4, :same_db=>true).gsub(/[+-]\d\d:\d\d"\)/, '")').should == "create_table(:t4) do\n column :c1, \"boolean\", :default=>false\n column :c2, \"varchar\", :default=>\"blah\"\n column :c3, \"integer\", :default=>-1\n column :c4, \"float\", :default=>1.0\n column :c5, \"decimal\", :default=>BigDecimal.new(\"0.1005E3\")\n column :c6, \"blob\", :default=>Sequel::SQL::Blob.new(\"blah\")\n column :c7, \"date\", :default=>Date.parse(\"2008-10-29\")\n column :c8, \"datetime\", :default=>DateTime.parse(\"2008-10-29T10:20:30\")\n column :c9, \"time\", :default=>Sequel::SQLTime.parse(\"10:20:30\")\n column :c10, \"interval\", :default=>\"'6 weeks'\".lit\nend"
|
|
268
268
|
end
|
|
269
269
|
|
|
270
270
|
it "should not use a '...'.lit as a fallback if using MySQL with the :same_db option" do
|
|
@@ -23,22 +23,19 @@ describe Sequel::Model, "dataset & schema" do
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
describe Sequel::Model, "table_exists?" do
|
|
26
|
-
|
|
27
|
-
before(:each) do
|
|
26
|
+
before do
|
|
28
27
|
MODEL_DB.reset
|
|
29
28
|
@model = Class.new(Sequel::Model(:items))
|
|
30
29
|
end
|
|
31
30
|
|
|
32
31
|
it "should get the table name and question the model's db if table_exists?" do
|
|
33
|
-
@model.should_receive(:
|
|
34
|
-
@model.
|
|
35
|
-
@model.table_exists?
|
|
32
|
+
@model.db.should_receive(:table_exists?).and_return(false)
|
|
33
|
+
@model.table_exists?.should == false
|
|
36
34
|
end
|
|
37
35
|
end
|
|
38
36
|
|
|
39
37
|
describe Sequel::Model, "create_table and schema" do
|
|
40
|
-
|
|
41
|
-
before(:each) do
|
|
38
|
+
before do
|
|
42
39
|
MODEL_DB.reset
|
|
43
40
|
@model = Class.new(Sequel::Model) do
|
|
44
41
|
set_schema(:items) do
|
|
@@ -84,19 +81,15 @@ describe Sequel::Model, "create_table and schema" do
|
|
|
84
81
|
end
|
|
85
82
|
|
|
86
83
|
describe Sequel::Model, "drop_table" do
|
|
87
|
-
|
|
88
|
-
before(:each) do
|
|
89
|
-
MODEL_DB.reset
|
|
84
|
+
before do
|
|
90
85
|
@model = Class.new(Sequel::Model(:items))
|
|
86
|
+
MODEL_DB.reset
|
|
91
87
|
end
|
|
92
88
|
|
|
93
89
|
it "should get the drop table SQL for the associated table and then execute the SQL." do
|
|
94
|
-
@model.should_receive(:table_name).and_return(:items)
|
|
95
|
-
@model.db.should_receive(:drop_table_sql).with(:items)
|
|
96
|
-
@model.db.should_receive(:execute).and_return(:true)
|
|
97
90
|
@model.drop_table
|
|
91
|
+
MODEL_DB.sqls.should == ['DROP TABLE items']
|
|
98
92
|
end
|
|
99
|
-
|
|
100
93
|
end
|
|
101
94
|
|
|
102
95
|
describe Sequel::Model, "create_table!" do
|
|
@@ -106,9 +99,8 @@ describe Sequel::Model, "create_table!" do
|
|
|
106
99
|
end
|
|
107
100
|
|
|
108
101
|
it "should drop table if it exists and then create the table" do
|
|
109
|
-
@model.should_receive(:drop_table).and_return(true)
|
|
110
|
-
@model.should_receive(:create_table).and_return(true)
|
|
111
102
|
@model.create_table!
|
|
103
|
+
MODEL_DB.sqls.should == ['DROP TABLE items', 'CREATE TABLE items ()']
|
|
112
104
|
end
|
|
113
105
|
end
|
|
114
106
|
|
|
@@ -120,13 +112,13 @@ describe Sequel::Model, "create_table?" do
|
|
|
120
112
|
|
|
121
113
|
it "should not create the table if it already exists" do
|
|
122
114
|
@model.should_receive(:table_exists?).and_return(true)
|
|
123
|
-
@model.
|
|
124
|
-
|
|
115
|
+
@model.create_table?
|
|
116
|
+
MODEL_DB.sqls.should == []
|
|
125
117
|
end
|
|
126
118
|
|
|
127
119
|
it "should create the table if it doesn't exist" do
|
|
128
120
|
@model.should_receive(:table_exists?).and_return(false)
|
|
129
|
-
@model.
|
|
130
|
-
|
|
121
|
+
@model.create_table?
|
|
122
|
+
MODEL_DB.sqls.should == ['CREATE TABLE items ()']
|
|
131
123
|
end
|
|
132
124
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
|
|
2
|
+
|
|
3
|
+
describe "serialization_modification_detection plugin" do
|
|
4
|
+
before do
|
|
5
|
+
@c = Class.new(Sequel::Model(:items))
|
|
6
|
+
@c.class_eval do
|
|
7
|
+
columns :id, :h
|
|
8
|
+
plugin :serialization, :yaml, :h
|
|
9
|
+
plugin :serialization_modification_detection
|
|
10
|
+
end
|
|
11
|
+
@o1 = @c.new
|
|
12
|
+
@o2 = @c.load(:id=>1, :h=>"--- {}\n\n")
|
|
13
|
+
MODEL_DB.reset
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should not detect columns that haven't been changed" do
|
|
17
|
+
@o2.changed_columns.should == []
|
|
18
|
+
@o2.h.should == {}
|
|
19
|
+
@o2.h[1] = 2
|
|
20
|
+
@o2.h.clear
|
|
21
|
+
@o2.changed_columns.should == []
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should detect columns that have been changed" do
|
|
25
|
+
@o2.changed_columns.should == []
|
|
26
|
+
@o2.h.should == {}
|
|
27
|
+
@o2.h[1] = 2
|
|
28
|
+
@o2.changed_columns.should == [:h]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should report correct changed_columns after saving" do
|
|
32
|
+
@o2.h[1] = 2
|
|
33
|
+
@o2.save_changes
|
|
34
|
+
@o2.changed_columns.should == []
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -54,6 +54,17 @@ describe Sequel::Model, "#sti_key" do
|
|
|
54
54
|
StiTest.all.collect{|x| x.class}.should == [StiTest, StiTestSub1, StiTestSub2]
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
it "should return rows with the correct class for subclasses based on the polymorphic_key value" do
|
|
58
|
+
class ::StiTestSub1Sub < StiTestSub1
|
|
59
|
+
end
|
|
60
|
+
ds = StiTestSub1.dataset
|
|
61
|
+
def ds.fetch_rows(sql)
|
|
62
|
+
yield({:kind=>'StiTestSub1'})
|
|
63
|
+
yield({:kind=>'StiTestSub1Sub'})
|
|
64
|
+
end
|
|
65
|
+
StiTestSub1.all.collect{|x| x.class}.should == [StiTestSub1, StiTestSub1Sub]
|
|
66
|
+
end
|
|
67
|
+
|
|
57
68
|
it "should fallback to the main class if the given class does not exist" do
|
|
58
69
|
def @ds.fetch_rows(sql)
|
|
59
70
|
yield({:kind=>'StiTestSub3'})
|
|
@@ -8,9 +8,11 @@ unless Sequel.const_defined?('Model')
|
|
|
8
8
|
require 'sequel/model'
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
Sequel.extension(*%w'string_date_time inflector pagination query pretty_table blank migration schema_dumper looser_typecasting sql_expr thread_local_timezones to_dot')
|
|
11
|
+
Sequel.extension(*%w'string_date_time inflector pagination query pretty_table blank migration schema_dumper looser_typecasting sql_expr thread_local_timezones to_dot columns_introspection')
|
|
12
12
|
{:hook_class_methods=>[], :schema=>[], :validation_class_methods=>[]}.each{|p, opts| Sequel::Model.plugin(p, *opts)}
|
|
13
13
|
|
|
14
|
+
Sequel::Dataset.introspect_all_columns if ENV['SEQUEL_COLUMNS_INTROSPECTION']
|
|
15
|
+
|
|
14
16
|
def skip_warn(s)
|
|
15
17
|
warn "Skipping test of #{s}" if ENV["SKIPPED_TEST_WARN"]
|
|
16
18
|
end
|
|
@@ -2,9 +2,7 @@ require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
|
|
|
2
2
|
|
|
3
3
|
describe Sequel::Model, "to_dot extension" do
|
|
4
4
|
def dot(ds)
|
|
5
|
-
|
|
6
|
-
ds.send(:_to_dot, a, "", 0, ds, 0)
|
|
7
|
-
a[2..-1]
|
|
5
|
+
Sequel::ToDot.new(ds).instance_variable_get(:@dot)[4...-1]
|
|
8
6
|
end
|
|
9
7
|
|
|
10
8
|
before do
|
|
@@ -123,7 +121,7 @@ END
|
|
|
123
121
|
end
|
|
124
122
|
|
|
125
123
|
it "should handle SQL::Subscript" do
|
|
126
|
-
dot(@ds.select(:a.sql_subscript(1))).should == ["1 -> 2 [label=\"select\"];", "2 [label=\"Array\"];", "2 -> 3 [label=\"0\"];", "3 [label=\"Subscript
|
|
124
|
+
dot(@ds.select(:a.sql_subscript(1))).should == ["1 -> 2 [label=\"select\"];", "2 [label=\"Array\"];", "2 -> 3 [label=\"0\"];", "3 [label=\"Subscript\"];", "3 -> 4 [label=\"f\"];", "4 [label=\":a\"];", "3 -> 5 [label=\"sub\"];", "5 [label=\"Array\"];", "5 -> 6 [label=\"0\"];", "6 [label=\"1\"];"]
|
|
127
125
|
end
|
|
128
126
|
|
|
129
127
|
it "should handle SQL::WindowFunction" do
|
|
@@ -135,7 +133,7 @@ END
|
|
|
135
133
|
end
|
|
136
134
|
|
|
137
135
|
it "should handle JOIN ON" do
|
|
138
|
-
dot(@ds.from(:a).join(:d, :b=>:c)).should == ["1 -> 2 [label=\"from\"];", "2 [label=\"Array\"];", "2 -> 3 [label=\"0\"];", "3 [label=\":a\"];", "1 -> 4 [label=\"join\"];", "4 [label=\"Array\"];", "4 -> 5 [label=\"0\"];", "5 [label=\"INNER JOIN ON\"];", "5 -> 6 [label=\"table\"];", "6 [label=\":d\"];", "5 -> 7 [label=\"on\"];", "7 [label=\"
|
|
136
|
+
dot(@ds.from(:a).join(:d, :b=>:c)).should == ["1 -> 2 [label=\"from\"];", "2 [label=\"Array\"];", "2 -> 3 [label=\"0\"];", "3 [label=\":a\"];", "1 -> 4 [label=\"join\"];", "4 [label=\"Array\"];", "4 -> 5 [label=\"0\"];", "5 [label=\"INNER JOIN ON\"];", "5 -> 6 [label=\"table\"];", "6 [label=\":d\"];", "5 -> 7 [label=\"on\"];", "7 [label=\"ComplexExpression: =\"];", "7 -> 8 [label=\"0\"];", "8 [label=\"QualifiedIdentifier\"];", "8 -> 9 [label=\"table\"];", "9 [label=\"\\\"d\\\"\"];", "8 -> 10 [label=\"column\"];", "10 [label=\"\\\"b\\\"\"];", "7 -> 11 [label=\"1\"];", "11 [label=\"QualifiedIdentifier\"];", "11 -> 12 [label=\"table\"];", "12 [label=\"\\\"a\\\"\"];", "11 -> 13 [label=\"column\"];", "13 [label=\"\\\"c\\\"\"];"]
|
|
139
137
|
end
|
|
140
138
|
|
|
141
139
|
it "should handle JOIN USING" do
|
|
@@ -36,6 +36,18 @@ describe "Sequel::Plugins::XmlSerializer" do
|
|
|
36
36
|
Album.from_xml(@album.to_xml).should == @album
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
it "should round trip successfully for namespaced models" do
|
|
40
|
+
module XmlSerializerTest
|
|
41
|
+
class Artist < Sequel::Model
|
|
42
|
+
plugin :xml_serializer
|
|
43
|
+
columns :id, :name
|
|
44
|
+
@db_schema = {:id=>{:type=>:integer}, :name=>{:type=>:string}}
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
artist = XmlSerializerTest::Artist.load(:id=>2, :name=>'YJM')
|
|
48
|
+
XmlSerializerTest::Artist.from_xml(artist.to_xml).should == artist
|
|
49
|
+
end
|
|
50
|
+
|
|
39
51
|
it "should round trip successfully with empty strings" do
|
|
40
52
|
artist = Artist.load(:id=>2, :name=>'')
|
|
41
53
|
Artist.from_xml(artist.to_xml).should == artist
|
|
@@ -106,13 +118,13 @@ describe "Sequel::Plugins::XmlSerializer" do
|
|
|
106
118
|
end
|
|
107
119
|
|
|
108
120
|
it "should support an :encoding option when serializing" do
|
|
109
|
-
["<?xml version=\"1.0\" encoding=\"
|
|
110
|
-
"<?xml version=\"1.0\" encoding=\"
|
|
121
|
+
["<?xml version=\"1.0\" encoding=\"UTF-8\"?><artist><id>2</id><name>YJM</name></artist>",
|
|
122
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><artist><name>YJM</name><id>2</id></artist>"].should include(@artist.to_xml(:encoding=>'UTF-8').gsub(/\n */m, ''))
|
|
111
123
|
end
|
|
112
124
|
|
|
113
125
|
it "should support a :builder_opts option when serializing" do
|
|
114
|
-
["<?xml version=\"1.0\" encoding=\"
|
|
115
|
-
"<?xml version=\"1.0\" encoding=\"
|
|
126
|
+
["<?xml version=\"1.0\" encoding=\"UTF-8\"?><artist><id>2</id><name>YJM</name></artist>",
|
|
127
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><artist><name>YJM</name><id>2</id></artist>"].should include(@artist.to_xml(:builder_opts=>{:encoding=>'UTF-8'}).gsub(/\n */m, ''))
|
|
116
128
|
end
|
|
117
129
|
|
|
118
130
|
it "should support an :types option when serializing" do
|