sequel 3.47.0 → 3.48.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.
- checksums.yaml +4 -4
- data/CHANGELOG +230 -0
- data/README.rdoc +31 -40
- data/Rakefile +1 -14
- data/doc/active_record.rdoc +29 -29
- data/doc/association_basics.rdoc +4 -13
- data/doc/cheat_sheet.rdoc +8 -6
- data/doc/code_order.rdoc +89 -0
- data/doc/core_extensions.rdoc +3 -3
- data/doc/dataset_basics.rdoc +7 -8
- data/doc/dataset_filtering.rdoc +7 -2
- data/doc/mass_assignment.rdoc +2 -3
- data/doc/migration.rdoc +8 -8
- data/doc/model_hooks.rdoc +11 -7
- data/doc/object_model.rdoc +2 -2
- data/doc/opening_databases.rdoc +5 -14
- data/doc/prepared_statements.rdoc +5 -9
- data/doc/querying.rdoc +23 -28
- data/doc/reflection.rdoc +11 -0
- data/doc/release_notes/3.48.0.txt +477 -0
- data/doc/schema_modification.rdoc +12 -5
- data/doc/security.rdoc +2 -2
- data/doc/sharding.rdoc +1 -2
- data/doc/sql.rdoc +10 -13
- data/doc/testing.rdoc +8 -4
- data/doc/transactions.rdoc +2 -2
- data/doc/validations.rdoc +40 -17
- data/doc/virtual_rows.rdoc +2 -2
- data/lib/sequel/adapters/ado.rb +25 -20
- data/lib/sequel/adapters/ado/access.rb +1 -0
- data/lib/sequel/adapters/ado/mssql.rb +1 -0
- data/lib/sequel/adapters/db2.rb +9 -7
- data/lib/sequel/adapters/dbi.rb +16 -16
- data/lib/sequel/adapters/do.rb +17 -18
- data/lib/sequel/adapters/do/mysql.rb +1 -0
- data/lib/sequel/adapters/do/postgres.rb +2 -0
- data/lib/sequel/adapters/do/sqlite.rb +1 -0
- data/lib/sequel/adapters/firebird.rb +5 -7
- data/lib/sequel/adapters/ibmdb.rb +23 -20
- data/lib/sequel/adapters/informix.rb +8 -2
- data/lib/sequel/adapters/jdbc.rb +39 -35
- data/lib/sequel/adapters/jdbc/as400.rb +1 -0
- data/lib/sequel/adapters/jdbc/cubrid.rb +1 -0
- data/lib/sequel/adapters/jdbc/db2.rb +1 -0
- data/lib/sequel/adapters/jdbc/derby.rb +1 -0
- data/lib/sequel/adapters/jdbc/firebird.rb +1 -0
- data/lib/sequel/adapters/jdbc/h2.rb +1 -0
- data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -0
- data/lib/sequel/adapters/jdbc/informix.rb +1 -0
- data/lib/sequel/adapters/jdbc/jtds.rb +1 -0
- data/lib/sequel/adapters/jdbc/mssql.rb +1 -0
- data/lib/sequel/adapters/jdbc/mysql.rb +1 -0
- data/lib/sequel/adapters/jdbc/oracle.rb +1 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +2 -0
- data/lib/sequel/adapters/jdbc/progress.rb +1 -0
- data/lib/sequel/adapters/jdbc/sqlite.rb +1 -0
- data/lib/sequel/adapters/jdbc/sqlserver.rb +1 -0
- data/lib/sequel/adapters/mock.rb +30 -31
- data/lib/sequel/adapters/mysql.rb +6 -7
- data/lib/sequel/adapters/mysql2.rb +5 -6
- data/lib/sequel/adapters/odbc.rb +22 -20
- data/lib/sequel/adapters/odbc/mssql.rb +1 -0
- data/lib/sequel/adapters/openbase.rb +4 -1
- data/lib/sequel/adapters/oracle.rb +10 -8
- data/lib/sequel/adapters/postgres.rb +12 -10
- data/lib/sequel/adapters/shared/access.rb +6 -0
- data/lib/sequel/adapters/shared/cubrid.rb +2 -0
- data/lib/sequel/adapters/shared/db2.rb +2 -0
- data/lib/sequel/adapters/shared/firebird.rb +2 -0
- data/lib/sequel/adapters/shared/informix.rb +2 -0
- data/lib/sequel/adapters/shared/mssql.rb +14 -8
- data/lib/sequel/adapters/shared/mysql.rb +6 -0
- data/lib/sequel/adapters/shared/oracle.rb +2 -0
- data/lib/sequel/adapters/shared/postgres.rb +14 -4
- data/lib/sequel/adapters/shared/progress.rb +1 -0
- data/lib/sequel/adapters/shared/sqlite.rb +4 -3
- data/lib/sequel/adapters/sqlite.rb +6 -7
- data/lib/sequel/adapters/swift.rb +20 -21
- data/lib/sequel/adapters/swift/mysql.rb +1 -0
- data/lib/sequel/adapters/swift/postgres.rb +2 -0
- data/lib/sequel/adapters/swift/sqlite.rb +1 -0
- data/lib/sequel/adapters/tinytds.rb +5 -6
- data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +68 -0
- data/lib/sequel/connection_pool.rb +1 -1
- data/lib/sequel/core.rb +57 -50
- data/lib/sequel/database/connecting.rb +9 -10
- data/lib/sequel/database/dataset.rb +11 -6
- data/lib/sequel/database/dataset_defaults.rb +61 -69
- data/lib/sequel/database/features.rb +21 -0
- data/lib/sequel/database/misc.rb +23 -3
- data/lib/sequel/database/query.rb +13 -7
- data/lib/sequel/database/schema_methods.rb +6 -6
- data/lib/sequel/database/transactions.rb +1 -0
- data/lib/sequel/dataset/actions.rb +51 -38
- data/lib/sequel/dataset/features.rb +1 -0
- data/lib/sequel/dataset/graph.rb +9 -33
- data/lib/sequel/dataset/misc.rb +30 -5
- data/lib/sequel/dataset/mutation.rb +2 -3
- data/lib/sequel/dataset/prepared_statements.rb +1 -1
- data/lib/sequel/dataset/query.rb +91 -27
- data/lib/sequel/dataset/sql.rb +40 -6
- data/lib/sequel/deprecated.rb +74 -0
- data/lib/sequel/deprecated_core_extensions.rb +135 -0
- data/lib/sequel/extensions/columns_introspection.rb +1 -5
- data/lib/sequel/extensions/core_extensions.rb +10 -3
- data/lib/sequel/extensions/date_arithmetic.rb +1 -0
- data/lib/sequel/extensions/empty_array_ignore_nulls.rb +33 -0
- data/lib/sequel/extensions/filter_having.rb +58 -0
- data/lib/sequel/extensions/graph_each.rb +63 -0
- data/lib/sequel/extensions/hash_aliases.rb +44 -0
- data/lib/sequel/extensions/looser_typecasting.rb +14 -3
- data/lib/sequel/extensions/migration.rb +2 -3
- data/lib/sequel/extensions/named_timezones.rb +14 -1
- data/lib/sequel/extensions/null_dataset.rb +7 -1
- data/lib/sequel/extensions/pagination.rb +15 -5
- data/lib/sequel/extensions/pg_auto_parameterize.rb +1 -0
- data/lib/sequel/extensions/pg_hstore_ops.rb +48 -14
- data/lib/sequel/extensions/pg_json.rb +7 -7
- data/lib/sequel/extensions/pg_range_ops.rb +8 -2
- data/lib/sequel/extensions/pg_statement_cache.rb +1 -0
- data/lib/sequel/extensions/pretty_table.rb +13 -4
- data/lib/sequel/extensions/query.rb +21 -4
- data/lib/sequel/extensions/ruby18_symbol_extensions.rb +22 -0
- data/lib/sequel/extensions/schema_caching.rb +10 -7
- data/lib/sequel/extensions/schema_dumper.rb +35 -48
- data/lib/sequel/extensions/select_remove.rb +13 -4
- data/lib/sequel/extensions/sequel_3_dataset_methods.rb +117 -0
- data/lib/sequel/extensions/set_overrides.rb +43 -0
- data/lib/sequel/extensions/to_dot.rb +6 -0
- data/lib/sequel/model.rb +12 -6
- data/lib/sequel/model/associations.rb +80 -38
- data/lib/sequel/model/base.rb +137 -52
- data/lib/sequel/model/errors.rb +7 -2
- data/lib/sequel/plugins/active_model.rb +13 -0
- data/lib/sequel/plugins/after_initialize.rb +43 -0
- data/lib/sequel/plugins/association_proxies.rb +63 -7
- data/lib/sequel/plugins/auto_validations.rb +56 -16
- data/lib/sequel/plugins/blacklist_security.rb +63 -0
- data/lib/sequel/plugins/class_table_inheritance.rb +9 -0
- data/lib/sequel/plugins/constraint_validations.rb +50 -8
- data/lib/sequel/plugins/dataset_associations.rb +2 -0
- data/lib/sequel/plugins/hook_class_methods.rb +7 -1
- data/lib/sequel/plugins/identity_map.rb +4 -0
- data/lib/sequel/plugins/json_serializer.rb +32 -13
- data/lib/sequel/plugins/optimistic_locking.rb +1 -1
- data/lib/sequel/plugins/rcte_tree.rb +4 -4
- data/lib/sequel/plugins/scissors.rb +33 -0
- data/lib/sequel/plugins/serialization.rb +1 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +6 -0
- data/lib/sequel/plugins/tree.rb +5 -1
- data/lib/sequel/plugins/validation_class_methods.rb +2 -1
- data/lib/sequel/plugins/validation_helpers.rb +15 -11
- data/lib/sequel/plugins/xml_serializer.rb +12 -3
- data/lib/sequel/sql.rb +12 -2
- data/lib/sequel/timezones.rb +1 -1
- data/lib/sequel/version.rb +1 -1
- data/lib/sequel_core.rb +1 -0
- data/lib/sequel_model.rb +1 -0
- data/spec/adapters/mssql_spec.rb +24 -57
- data/spec/adapters/postgres_spec.rb +27 -55
- data/spec/adapters/spec_helper.rb +1 -1
- data/spec/adapters/sqlite_spec.rb +1 -1
- data/spec/bin_spec.rb +251 -0
- data/spec/core/database_spec.rb +46 -32
- data/spec/core/dataset_spec.rb +233 -181
- data/spec/core/deprecated_spec.rb +78 -0
- data/spec/core/expression_filters_spec.rb +3 -4
- data/spec/core/mock_adapter_spec.rb +9 -9
- data/spec/core/object_graph_spec.rb +9 -19
- data/spec/core/schema_spec.rb +3 -1
- data/spec/core/spec_helper.rb +19 -0
- data/spec/core_extensions_spec.rb +80 -30
- data/spec/extensions/after_initialize_spec.rb +24 -0
- data/spec/extensions/association_proxies_spec.rb +37 -1
- data/spec/extensions/auto_validations_spec.rb +20 -4
- data/spec/extensions/blacklist_security_spec.rb +87 -0
- data/spec/extensions/boolean_readers_spec.rb +2 -1
- data/spec/extensions/class_table_inheritance_spec.rb +7 -0
- data/spec/extensions/columns_introspection_spec.rb +3 -3
- data/spec/extensions/constraint_validations_plugin_spec.rb +83 -5
- data/spec/extensions/core_refinements_spec.rb +7 -7
- data/spec/extensions/dataset_associations_spec.rb +2 -2
- data/spec/extensions/date_arithmetic_spec.rb +1 -1
- data/spec/extensions/defaults_setter_spec.rb +2 -1
- data/spec/extensions/empty_array_ignore_nulls_spec.rb +24 -0
- data/spec/extensions/filter_having_spec.rb +40 -0
- data/spec/extensions/graph_each_spec.rb +109 -0
- data/spec/extensions/hash_aliases_spec.rb +16 -0
- data/spec/extensions/hook_class_methods_spec.rb +2 -2
- data/spec/extensions/identity_map_spec.rb +3 -3
- data/spec/extensions/json_serializer_spec.rb +19 -19
- data/spec/extensions/lazy_attributes_spec.rb +1 -0
- data/spec/extensions/list_spec.rb +13 -13
- data/spec/extensions/looser_typecasting_spec.rb +10 -3
- data/spec/extensions/many_through_many_spec.rb +1 -1
- data/spec/extensions/migration_spec.rb +7 -7
- data/spec/extensions/named_timezones_spec.rb +6 -0
- data/spec/extensions/nested_attributes_spec.rb +2 -2
- data/spec/extensions/null_dataset_spec.rb +1 -1
- data/spec/extensions/pagination_spec.rb +2 -2
- data/spec/extensions/pg_hstore_ops_spec.rb +75 -0
- data/spec/extensions/pg_range_ops_spec.rb +4 -2
- data/spec/extensions/pg_row_plugin_spec.rb +1 -1
- data/spec/extensions/pretty_table_spec.rb +1 -1
- data/spec/extensions/query_literals_spec.rb +1 -1
- data/spec/extensions/query_spec.rb +3 -3
- data/spec/extensions/schema_caching_spec.rb +3 -3
- data/spec/extensions/schema_dumper_spec.rb +27 -2
- data/spec/extensions/schema_spec.rb +2 -2
- data/spec/extensions/scissors_spec.rb +26 -0
- data/spec/extensions/select_remove_spec.rb +1 -1
- data/spec/extensions/sequel_3_dataset_methods_spec.rb +102 -0
- data/spec/extensions/set_overrides_spec.rb +45 -0
- data/spec/extensions/single_table_inheritance_spec.rb +10 -0
- data/spec/extensions/spec_helper.rb +24 -1
- data/spec/extensions/static_cache_spec.rb +1 -1
- data/spec/extensions/string_stripper_spec.rb +2 -1
- data/spec/extensions/to_dot_spec.rb +1 -1
- data/spec/extensions/typecast_on_load_spec.rb +3 -2
- data/spec/extensions/update_primary_key_spec.rb +2 -2
- data/spec/extensions/validation_class_methods_spec.rb +19 -19
- data/spec/extensions/validation_helpers_spec.rb +30 -21
- data/spec/extensions/xml_serializer_spec.rb +5 -5
- data/spec/integration/associations_test.rb +10 -30
- data/spec/integration/dataset_test.rb +20 -24
- data/spec/integration/eager_loader_test.rb +5 -5
- data/spec/integration/model_test.rb +3 -3
- data/spec/integration/plugin_test.rb +7 -39
- data/spec/integration/schema_test.rb +4 -38
- data/spec/integration/spec_helper.rb +2 -1
- data/spec/model/association_reflection_spec.rb +70 -5
- data/spec/model/associations_spec.rb +11 -11
- data/spec/model/base_spec.rb +25 -8
- data/spec/model/class_dataset_methods_spec.rb +143 -0
- data/spec/model/dataset_methods_spec.rb +1 -1
- data/spec/model/eager_loading_spec.rb +25 -25
- data/spec/model/hooks_spec.rb +1 -1
- data/spec/model/model_spec.rb +22 -7
- data/spec/model/plugins_spec.rb +1 -6
- data/spec/model/record_spec.rb +37 -29
- data/spec/model/spec_helper.rb +23 -1
- data/spec/model/validations_spec.rb +15 -17
- metadata +32 -3
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "Sequel::Deprecated" do
|
|
4
|
+
before do
|
|
5
|
+
@d = Sequel::Deprecation
|
|
6
|
+
@prev_prefix = @d.prefix
|
|
7
|
+
@prev_output = @d.output
|
|
8
|
+
@prev_backtrace_filter = @d.backtrace_filter
|
|
9
|
+
@output = []
|
|
10
|
+
def @output.puts(s)
|
|
11
|
+
self << s
|
|
12
|
+
end
|
|
13
|
+
@d.prefix = false
|
|
14
|
+
@d.output = @output
|
|
15
|
+
@d.backtrace_filter = false
|
|
16
|
+
end
|
|
17
|
+
after do
|
|
18
|
+
@d.prefix = @prev_prefix
|
|
19
|
+
@d.output = @prev_output
|
|
20
|
+
@d.backtrace_filter = @prev_backtrace_filter
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
specify "should output full messages to the given output" do
|
|
24
|
+
@d.deprecate("foo")
|
|
25
|
+
@output.should == ['foo']
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
specify "should consider two arguments to be a method name and additional text" do
|
|
29
|
+
@d.deprecate("foo", "Use bar instead")
|
|
30
|
+
@output.should == ['foo is deprecated and will be removed in Sequel 4.0. Use bar instead.']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
specify "should include a prefix if set" do
|
|
34
|
+
@d.prefix = "DEPWARN: "
|
|
35
|
+
@d.deprecate("foo")
|
|
36
|
+
@output.should == ['DEPWARN: foo']
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
specify "should not output anything if output is false" do
|
|
40
|
+
@d.output = false
|
|
41
|
+
proc{@d.deprecate("foo")}.should_not raise_error
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
specify "should include full backtrace if backtrace_filter is true" do
|
|
45
|
+
@d.backtrace_filter = true
|
|
46
|
+
@d.deprecate("foo")
|
|
47
|
+
@output.first.should == 'foo'
|
|
48
|
+
(4..100).should include(@output.count)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
specify "should include given lines of backtrace if backtrace_filter is an integer" do
|
|
52
|
+
@d.backtrace_filter = 1
|
|
53
|
+
@d.deprecate("foo")
|
|
54
|
+
@output.first.should == 'foo'
|
|
55
|
+
@output.count.should == 2
|
|
56
|
+
|
|
57
|
+
@output.clear
|
|
58
|
+
@d.backtrace_filter = 3
|
|
59
|
+
@d.deprecate("foo")
|
|
60
|
+
@output.first.should == 'foo'
|
|
61
|
+
@output.count.should == 4
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
specify "should select backtrace lines if backtrace_filter is a proc" do
|
|
65
|
+
@d.backtrace_filter = lambda{|line, line_no| line_no < 3 && line =~ /./}
|
|
66
|
+
@d.deprecate("foo")
|
|
67
|
+
@output.first.should == 'foo'
|
|
68
|
+
@output.count.should == 4
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
specify "should have deprecated_module return a module where all instance methods are marked deprecated" do
|
|
72
|
+
m = Module.new{def foo; 1 end}
|
|
73
|
+
dm = @d.deprecated_module(m){|meth| ["Module##{meth}", "Load the bar extension"]}
|
|
74
|
+
dm.should_not == m
|
|
75
|
+
c = Class.new{include dm}.new.foo.should == 1
|
|
76
|
+
@output.should == ['Module#foo is deprecated and will be removed in Sequel 4.0. Load the bar extension.']
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -220,10 +220,9 @@ describe "Blockless Ruby Filters" do
|
|
|
220
220
|
y.lit.should == y
|
|
221
221
|
end
|
|
222
222
|
|
|
223
|
-
it "should return have .sql_literal
|
|
223
|
+
it "should return have .sql_literal return the literal SQL for the expression" do
|
|
224
224
|
y = Sequel.expr(:x) + 1
|
|
225
225
|
y.sql_literal(@d).should == '(x + 1)'
|
|
226
|
-
y.sql_literal(@d).should == y.to_s(@d)
|
|
227
226
|
y.sql_literal(@d).should == @d.literal(y)
|
|
228
227
|
end
|
|
229
228
|
|
|
@@ -484,7 +483,7 @@ describe Sequel::SQL::VirtualRow do
|
|
|
484
483
|
class << @d; remove_method :supports_window_functions? end
|
|
485
484
|
meta_def(@d, :supports_window_functions?){false}
|
|
486
485
|
proc{@d.l{count(:over, :* =>true, :partition=>a, :order=>b, :window=>:win, :frame=>:rows){}}}.should raise_error(Sequel::Error)
|
|
487
|
-
proc{Sequel
|
|
486
|
+
proc{Sequel.mock.dataset.filter{count(:over, :* =>true, :partition=>a, :order=>b, :window=>:win, :frame=>:rows){}}.sql}.should raise_error(Sequel::Error)
|
|
488
487
|
end
|
|
489
488
|
|
|
490
489
|
it "should deal with classes without requiring :: prefix" do
|
|
@@ -932,7 +931,7 @@ end
|
|
|
932
931
|
describe Sequel::SQL::Subscript do
|
|
933
932
|
before do
|
|
934
933
|
@s = Sequel::SQL::Subscript.new(:a, [1])
|
|
935
|
-
@ds = Sequel
|
|
934
|
+
@ds = Sequel.mock.dataset
|
|
936
935
|
end
|
|
937
936
|
|
|
938
937
|
specify "should have | return a new non-nested subscript" do
|
|
@@ -130,8 +130,8 @@ describe "Sequel Mock Adapter" do
|
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
specify "should raise Error if given an invalid object to fetch" do
|
|
133
|
-
proc{Sequel.mock(:fetch=>Class.new).get(
|
|
134
|
-
proc{Sequel.mock(:fetch=>Object.new).get(
|
|
133
|
+
proc{Sequel.mock(:fetch=>Class.new).get(:a)}.should raise_error(Sequel::Error)
|
|
134
|
+
proc{Sequel.mock(:fetch=>Object.new).get(:a)}.should raise_error(Sequel::Error)
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
specify "should be able to set the number of rows modified by update and delete using :numrows option as an integer" do
|
|
@@ -417,12 +417,12 @@ describe "Sequel Mock Adapter" do
|
|
|
417
417
|
|
|
418
418
|
specify "should be able to load dialects based on the database name" do
|
|
419
419
|
begin
|
|
420
|
-
qi = class Sequel::Database;
|
|
421
|
-
ii = class Sequel::Database;
|
|
422
|
-
io = class Sequel::Database;
|
|
420
|
+
qi = class Sequel::Database; @quote_identifiers; end
|
|
421
|
+
ii = class Sequel::Database; @identifier_input_method; end
|
|
422
|
+
io = class Sequel::Database; @identifier_output_method; end
|
|
423
423
|
Sequel.quote_identifiers = nil
|
|
424
|
-
class Sequel::Database;
|
|
425
|
-
class Sequel::Database;
|
|
424
|
+
class Sequel::Database; @identifier_input_method=nil; end
|
|
425
|
+
class Sequel::Database; @identifier_output_method=nil; end
|
|
426
426
|
Sequel.mock(:host=>'access').select(Date.new(2011, 12, 13)).sql.should == 'SELECT #2011-12-13#'
|
|
427
427
|
Sequel.mock(:host=>'db2').select(1).sql.should == 'SELECT 1 FROM "SYSIBM"."SYSDUMMY1"'
|
|
428
428
|
Sequel.mock(:host=>'firebird')[:a].distinct.limit(1, 2).sql.should == 'SELECT DISTINCT FIRST 1 SKIP 2 * FROM "A"'
|
|
@@ -434,8 +434,8 @@ describe "Sequel Mock Adapter" do
|
|
|
434
434
|
Sequel.mock(:host=>'sqlite')[:a___b].sql.should == "SELECT * FROM `a` AS 'b'"
|
|
435
435
|
ensure
|
|
436
436
|
Sequel.quote_identifiers = qi
|
|
437
|
-
Sequel::Database.send(:
|
|
438
|
-
Sequel::Database.send(:
|
|
437
|
+
Sequel::Database.send(:instance_variable_set, :@identifier_input_method, ii)
|
|
438
|
+
Sequel::Database.send(:instance_variable_set, :@identifier_output_method, io)
|
|
439
439
|
end
|
|
440
440
|
end
|
|
441
441
|
|
|
@@ -43,28 +43,18 @@ describe Sequel::Dataset, " graphing" do
|
|
|
43
43
|
it "#graph should use currently selected columns as the basis for the selected columns in a new graph" do
|
|
44
44
|
ds = @ds1.select(:id).graph(@ds2, :x=>:id)
|
|
45
45
|
ds.sql.should == 'SELECT points.id, lines.id AS lines_id, lines.x, lines.y, lines.graph_id FROM points LEFT OUTER JOIN lines ON (lines.x = points.id)'
|
|
46
|
-
ds._fetch = {:id=>1, :lines_id=>2, :x=>3, :y=>4, :graph_id=>5}
|
|
47
|
-
ds.all.should == [{:points=>{:id=>1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
|
|
48
46
|
|
|
49
47
|
ds = @ds1.select(:id, :x).graph(@ds2, :x=>:id)
|
|
50
48
|
ds.sql.should == 'SELECT points.id, points.x, lines.id AS lines_id, lines.x AS lines_x, lines.y, lines.graph_id FROM points LEFT OUTER JOIN lines ON (lines.x = points.id)'
|
|
51
|
-
ds._fetch = {:id=>1, :x=>-1, :lines_id=>2, :lines_x=>3, :y=>4, :graph_id=>5}
|
|
52
|
-
ds.all.should == [{:points=>{:id=>1, :x=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
|
|
53
49
|
|
|
54
50
|
ds = @ds1.select(Sequel.identifier(:id), Sequel.qualify(:points, :x)).graph(@ds2, :x=>:id)
|
|
55
51
|
ds.sql.should == 'SELECT points.id, points.x, lines.id AS lines_id, lines.x AS lines_x, lines.y, lines.graph_id FROM points LEFT OUTER JOIN lines ON (lines.x = points.id)'
|
|
56
|
-
ds._fetch = {:id=>1, :x=>-1, :lines_id=>2, :lines_x=>3, :y=>4, :graph_id=>5}
|
|
57
|
-
ds.all.should == [{:points=>{:id=>1, :x=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
|
|
58
52
|
|
|
59
53
|
ds = @ds1.select(Sequel.identifier(:id).qualify(:points), Sequel.identifier(:x).as(:y)).graph(@ds2, :x=>:id)
|
|
60
54
|
ds.sql.should == 'SELECT points.id, points.x AS y, lines.id AS lines_id, lines.x, lines.y AS lines_y, lines.graph_id FROM points LEFT OUTER JOIN lines ON (lines.x = points.id)'
|
|
61
|
-
ds._fetch = {:id=>1, :y=>-1, :lines_id=>2, :x=>3, :lines_y=>4, :graph_id=>5}
|
|
62
|
-
ds.all.should == [{:points=>{:id=>1, :y=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
|
|
63
55
|
|
|
64
56
|
ds = @ds1.select(:id, Sequel.identifier(:x).qualify(Sequel.identifier(:points)).as(Sequel.identifier(:y))).graph(@ds2, :x=>:id)
|
|
65
57
|
ds.sql.should == 'SELECT points.id, points.x AS y, lines.id AS lines_id, lines.x, lines.y AS lines_y, lines.graph_id FROM points LEFT OUTER JOIN lines ON (lines.x = points.id)'
|
|
66
|
-
ds._fetch = {:id=>1, :y=>-1, :lines_id=>2, :x=>3, :lines_y=>4, :graph_id=>5}
|
|
67
|
-
ds.all.should == [{:points=>{:id=>1, :y=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
|
|
68
58
|
end
|
|
69
59
|
|
|
70
60
|
it "#graph should raise error if currently selected expressions cannot be handled" do
|
|
@@ -215,7 +205,7 @@ describe Sequel::Dataset, " graphing" do
|
|
|
215
205
|
].should(include(ds.sql))
|
|
216
206
|
end
|
|
217
207
|
|
|
218
|
-
|
|
208
|
+
qspecify "#graph_each should split the result set into component tables" do
|
|
219
209
|
@db.fetch = [[{:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7}],
|
|
220
210
|
[{:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7, :graphs_id=>8, :name=>9, :graphs_x=>10, :graphs_y=>11, :graphs_lines_x=>12}],
|
|
221
211
|
[{:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7, :graph_id_0=>8, :graph_x=>9, :graph_y=>10, :graph_graph_id=>11}]]
|
|
@@ -230,7 +220,7 @@ describe Sequel::Dataset, " graphing" do
|
|
|
230
220
|
@ds1.graph(@ds2, :x=>:id).ungraphed.all.should == [{:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7}]
|
|
231
221
|
end
|
|
232
222
|
|
|
233
|
-
|
|
223
|
+
qspecify "#graph_each should give a nil value instead of a hash when all values for a table are nil" do
|
|
234
224
|
@db.fetch = [[{:id=>1,:x=>2,:y=>3,:lines_id=>nil,:lines_x=>nil,:lines_y=>nil,:graph_id=>nil}],
|
|
235
225
|
[{:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7, :graphs_id=>nil, :name=>nil, :graphs_x=>nil, :graphs_y=>nil, :graphs_lines_x=>nil},
|
|
236
226
|
{:id=>2,:x=>4,:y=>5,:lines_id=>nil,:lines_x=>nil,:lines_y=>nil,:graph_id=>nil, :graphs_id=>nil, :name=>nil, :graphs_x=>nil, :graphs_y=>nil, :graphs_lines_x=>nil},
|
|
@@ -244,17 +234,17 @@ describe Sequel::Dataset, " graphing" do
|
|
|
244
234
|
{:points=>{:id=>3, :x=>5, :y=>6}, :lines=>{:id=>7, :x=>5, :y=>8, :graph_id=>9}, :graphs=>{:id=>9, :name=>10, :x=>10, :y=>11, :lines_x=>12}}]
|
|
245
235
|
end
|
|
246
236
|
|
|
247
|
-
|
|
237
|
+
qspecify "#graph_each should not give a nil value instead of a hash when any value for a table is false" do
|
|
248
238
|
@db.fetch = {:id=>1,:x=>2,:y=>3,:lines_id=>nil,:lines_x=>false,:lines_y=>nil,:graph_id=>nil}
|
|
249
239
|
@ds1.graph(@ds2, :x=>:id).all.should == [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>nil, :x=>false, :y=>nil, :graph_id=>nil}}]
|
|
250
240
|
end
|
|
251
241
|
|
|
252
|
-
|
|
242
|
+
qspecify "#graph_each should not included tables graphed with the :select => false option in the result set" do
|
|
253
243
|
@db.fetch = {:id=>1,:x=>2,:y=>3,:graphs_id=>8, :name=>9, :graphs_x=>10, :graphs_y=>11, :lines_x=>12}
|
|
254
244
|
@ds1.graph(:lines, {:x=>:id}, :select=>false).graph(:graphs, :id=>:graph_id).all.should == [{:points=>{:id=>1, :x=>2, :y=>3}, :graphs=>{:id=>8, :name=>9, :x=>10, :y=>11, :lines_x=>12}}]
|
|
255
245
|
end
|
|
256
246
|
|
|
257
|
-
|
|
247
|
+
qspecify "#graph_each should only include the columns selected with #set_graph_aliases and #add_graph_aliases, if called" do
|
|
258
248
|
@db.fetch = [nil, [{:x=>2,:y=>3}], nil, [{:x=>2}], [{:x=>2, :q=>18}]]
|
|
259
249
|
|
|
260
250
|
@ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>[:points, :x], :y=>[:lines, :y]).all.should == [{:points=>{:x=>2}, :lines=>{:y=>3}}]
|
|
@@ -264,22 +254,22 @@ describe Sequel::Dataset, " graphing" do
|
|
|
264
254
|
ds.all.should == [{:points=>{:x=>2, :r=>18}, :lines=>nil}]
|
|
265
255
|
end
|
|
266
256
|
|
|
267
|
-
|
|
257
|
+
qspecify "#graph_each should correctly map values when #set_graph_aliases is used with a third argument for each entry" do
|
|
268
258
|
@db.fetch = [nil, {:x=>2,:y=>3}]
|
|
269
259
|
@ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>[:points, :z1, 2], :y=>[:lines, :z2, Sequel.function(:random)]).all.should == [{:points=>{:z1=>2}, :lines=>{:z2=>3}}]
|
|
270
260
|
end
|
|
271
261
|
|
|
272
|
-
|
|
262
|
+
qspecify "#graph_each should correctly map values when #set_graph_aliases is used with a single argument for each entry" do
|
|
273
263
|
@db.fetch = [nil, {:x=>2,:y=>3}]
|
|
274
264
|
@ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>[:points], :y=>[:lines]).all.should == [{:points=>{:x=>2}, :lines=>{:y=>3}}]
|
|
275
265
|
end
|
|
276
266
|
|
|
277
|
-
|
|
267
|
+
qspecify "#graph_each should correctly map values when #set_graph_aliases is used with a symbol for each entry" do
|
|
278
268
|
@db.fetch = [nil, {:x=>2,:y=>3}]
|
|
279
269
|
@ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>:points, :y=>:lines).all.should == [{:points=>{:x=>2}, :lines=>{:y=>3}}]
|
|
280
270
|
end
|
|
281
271
|
|
|
282
|
-
|
|
272
|
+
qspecify "#graph_each should run the row_proc for graphed datasets" do
|
|
283
273
|
@ds1.row_proc = proc{|h| h.keys.each{|k| h[k] *= 2}; h}
|
|
284
274
|
@ds2.row_proc = proc{|h| h.keys.each{|k| h[k] *= 3}; h}
|
|
285
275
|
@db.fetch = {:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7}
|
data/spec/core/schema_spec.rb
CHANGED
|
@@ -1125,7 +1125,7 @@ describe "Database#create_table" do
|
|
|
1125
1125
|
'CREATE UNIQUE INDEX test_tmp_name_index ON test_tmp (name)']
|
|
1126
1126
|
end
|
|
1127
1127
|
|
|
1128
|
-
|
|
1128
|
+
qspecify "should not use default schema when creating a temporary table" do
|
|
1129
1129
|
@db.default_schema = :foo
|
|
1130
1130
|
@db.create_table :test_tmp, :temp => true do
|
|
1131
1131
|
column :name, :text
|
|
@@ -1480,5 +1480,7 @@ describe "Schema Parser" do
|
|
|
1480
1480
|
@db = Sequel.mock(:host=>'mysql')
|
|
1481
1481
|
@db.extend(sm)
|
|
1482
1482
|
@db.schema(:set).first.last[:type].should == :set
|
|
1483
|
+
@db.schema(:mediumint).first.last[:type].should == :integer
|
|
1484
|
+
@db.schema(:mediumtext).first.last[:type].should == :string
|
|
1483
1485
|
end
|
|
1484
1486
|
end
|
data/spec/core/spec_helper.rb
CHANGED
|
@@ -10,11 +10,30 @@ unless Object.const_defined?('Sequel')
|
|
|
10
10
|
SEQUEL_NO_CORE_EXTENSIONS = true
|
|
11
11
|
require 'sequel/core'
|
|
12
12
|
end
|
|
13
|
+
Sequel::Deprecation.backtrace_filter = lambda{|line, lineno| lineno < 4 || line =~ /_spec\.rb/}
|
|
13
14
|
|
|
14
15
|
(defined?(RSpec) ? RSpec::Core::ExampleGroup : Spec::Example::ExampleGroup).class_eval do
|
|
15
16
|
def meta_def(obj, name, &block)
|
|
16
17
|
(class << obj; self end).send(:define_method, name, &block)
|
|
17
18
|
end
|
|
19
|
+
|
|
20
|
+
if ENV['SEQUEL_DEPRECATION_WARNINGS']
|
|
21
|
+
class << self
|
|
22
|
+
alias qspecify specify
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
def self.qspecify(*a, &block)
|
|
26
|
+
specify(*a) do
|
|
27
|
+
begin
|
|
28
|
+
output = Sequel::Deprecation.output
|
|
29
|
+
Sequel::Deprecation.output = false
|
|
30
|
+
instance_exec(&block)
|
|
31
|
+
ensure
|
|
32
|
+
Sequel::Deprecation.output = output
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
18
37
|
end
|
|
19
38
|
|
|
20
39
|
if ENV['SEQUEL_COLUMNS_INTROSPECTION']
|
|
@@ -7,7 +7,12 @@ end
|
|
|
7
7
|
|
|
8
8
|
unless Object.const_defined?('Sequel') && Sequel.const_defined?('Model')
|
|
9
9
|
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
|
|
10
|
-
|
|
10
|
+
if dep_core_extensions = ENV['SEQUEL_DEPRECATED_CORE_EXTENSIONS']
|
|
11
|
+
require 'sequel'
|
|
12
|
+
else
|
|
13
|
+
require 'sequel/no_core_ext'
|
|
14
|
+
end
|
|
15
|
+
Sequel::Deprecation.backtrace_filter = false
|
|
11
16
|
end
|
|
12
17
|
|
|
13
18
|
Sequel.quote_identifiers = false
|
|
@@ -16,7 +21,12 @@ Sequel.identifier_output_method = nil
|
|
|
16
21
|
|
|
17
22
|
Regexp.send(:include, Sequel::SQL::StringMethods)
|
|
18
23
|
String.send(:include, Sequel::SQL::StringMethods)
|
|
19
|
-
|
|
24
|
+
if dep_core_extensions.nil? || dep_core_extensions =~ /OVERRIDDEN/
|
|
25
|
+
Sequel.extension :core_extensions
|
|
26
|
+
end
|
|
27
|
+
if RUBY_VERSION < '1.9.0' && (dep_core_extensions.nil? || dep_core_extensions =~ /SYMBOL18/)
|
|
28
|
+
Sequel.extension :ruby18_symbol_extensions
|
|
29
|
+
end
|
|
20
30
|
|
|
21
31
|
describe "Sequel core extensions" do
|
|
22
32
|
specify "should have Sequel.core_extensions? be true if enabled" do
|
|
@@ -351,19 +361,47 @@ describe "String#to_sequel_blob" do
|
|
|
351
361
|
end
|
|
352
362
|
end
|
|
353
363
|
|
|
364
|
+
describe "String cast methods" do
|
|
365
|
+
before do
|
|
366
|
+
@ds = Sequel.mock.dataset
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
specify "should support cast method" do
|
|
370
|
+
@ds.literal('abc'.cast(:integer)).should == "CAST('abc' AS integer)"
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
specify "should support cast_numeric and cast_string" do
|
|
374
|
+
x = 'abc'.cast_numeric
|
|
375
|
+
x.should be_a_kind_of(Sequel::SQL::NumericExpression)
|
|
376
|
+
@ds.literal(x).should == "CAST('abc' AS integer)"
|
|
377
|
+
|
|
378
|
+
x = 'abc'.cast_numeric(:real)
|
|
379
|
+
x.should be_a_kind_of(Sequel::SQL::NumericExpression)
|
|
380
|
+
@ds.literal(x).should == "CAST('abc' AS real)"
|
|
381
|
+
|
|
382
|
+
x = 'abc'.cast_string
|
|
383
|
+
x.should be_a_kind_of(Sequel::SQL::StringExpression)
|
|
384
|
+
@ds.literal(x).should == "CAST('abc' AS varchar(255))"
|
|
385
|
+
|
|
386
|
+
x = 'abc'.cast_string(:varchar)
|
|
387
|
+
x.should be_a_kind_of(Sequel::SQL::StringExpression)
|
|
388
|
+
@ds.literal(x).should == "CAST('abc' AS varchar(255))"
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
|
|
354
392
|
describe "#desc" do
|
|
355
393
|
before do
|
|
356
394
|
@ds = Sequel::Dataset.new(nil)
|
|
357
395
|
end
|
|
358
396
|
|
|
359
397
|
specify "should format a DESC clause for a column ref" do
|
|
360
|
-
:test.desc
|
|
398
|
+
@ds.literal(:test.desc).should == 'test DESC'
|
|
361
399
|
|
|
362
|
-
:items__price.desc
|
|
400
|
+
@ds.literal(:items__price.desc).should == 'items.price DESC'
|
|
363
401
|
end
|
|
364
402
|
|
|
365
403
|
specify "should format a DESC clause for a function" do
|
|
366
|
-
:avg.sql_function(:test).desc
|
|
404
|
+
@ds.literal(:avg.sql_function(:test).desc).should == 'avg(test) DESC'
|
|
367
405
|
end
|
|
368
406
|
end
|
|
369
407
|
|
|
@@ -373,13 +411,13 @@ describe "#asc" do
|
|
|
373
411
|
end
|
|
374
412
|
|
|
375
413
|
specify "should format a ASC clause for a column ref" do
|
|
376
|
-
:test.asc
|
|
414
|
+
@ds.literal(:test.asc).should == 'test ASC'
|
|
377
415
|
|
|
378
|
-
:items__price.asc
|
|
416
|
+
@ds.literal(:items__price.asc).should == 'items.price ASC'
|
|
379
417
|
end
|
|
380
418
|
|
|
381
419
|
specify "should format a ASC clause for a function" do
|
|
382
|
-
:avg.sql_function(:test).asc
|
|
420
|
+
@ds.literal(:avg.sql_function(:test).asc).should == 'avg(test) ASC'
|
|
383
421
|
end
|
|
384
422
|
end
|
|
385
423
|
|
|
@@ -389,17 +427,17 @@ describe "#as" do
|
|
|
389
427
|
end
|
|
390
428
|
|
|
391
429
|
specify "should format a AS clause for a column ref" do
|
|
392
|
-
:test.as(:t)
|
|
430
|
+
@ds.literal(:test.as(:t)).should == 'test AS t'
|
|
393
431
|
|
|
394
|
-
:items__price.as(:p)
|
|
432
|
+
@ds.literal(:items__price.as(:p)).should == 'items.price AS p'
|
|
395
433
|
end
|
|
396
434
|
|
|
397
435
|
specify "should format a AS clause for a function" do
|
|
398
|
-
:avg.sql_function(:test).as(:avg)
|
|
436
|
+
@ds.literal(:avg.sql_function(:test).as(:avg)).should == 'avg(test) AS avg'
|
|
399
437
|
end
|
|
400
438
|
|
|
401
439
|
specify "should format a AS clause for a literal value" do
|
|
402
|
-
'abc'.as(:abc)
|
|
440
|
+
@ds.literal('abc'.as(:abc)).should == "'abc' AS abc"
|
|
403
441
|
end
|
|
404
442
|
end
|
|
405
443
|
|
|
@@ -464,17 +502,17 @@ describe "Symbol#*" do
|
|
|
464
502
|
end
|
|
465
503
|
|
|
466
504
|
specify "should format a qualified wildcard if no argument" do
|
|
467
|
-
:xyz
|
|
468
|
-
:abc
|
|
505
|
+
@ds.literal(:xyz.*).should == 'xyz.*'
|
|
506
|
+
@ds.literal(:abc.*).should == 'abc.*'
|
|
469
507
|
end
|
|
470
508
|
|
|
471
509
|
specify "should format a filter expression if an argument" do
|
|
472
|
-
:xyz.*(3)
|
|
473
|
-
:abc.*(5)
|
|
510
|
+
@ds.literal(:xyz.*(3)).should == '(xyz * 3)'
|
|
511
|
+
@ds.literal(:abc.*(5)).should == '(abc * 5)'
|
|
474
512
|
end
|
|
475
513
|
|
|
476
514
|
specify "should support qualified symbols if no argument" do
|
|
477
|
-
:xyz__abc
|
|
515
|
+
@ds.literal(:xyz__abc.*).should == 'xyz.abc.*'
|
|
478
516
|
end
|
|
479
517
|
end
|
|
480
518
|
|
|
@@ -528,12 +566,12 @@ describe "Symbol" do
|
|
|
528
566
|
end
|
|
529
567
|
|
|
530
568
|
specify "should support sql_function method" do
|
|
531
|
-
:COUNT.sql_function('1')
|
|
569
|
+
@ds.literal(:COUNT.sql_function('1')).should == "COUNT('1')"
|
|
532
570
|
@ds.select(:COUNT.sql_function('1')).sql.should == "SELECT COUNT('1')"
|
|
533
571
|
end
|
|
534
572
|
|
|
535
573
|
specify "should support cast method" do
|
|
536
|
-
:abc.cast(:integer)
|
|
574
|
+
@ds.literal(:abc.cast(:integer)).should == "CAST(abc AS integer)"
|
|
537
575
|
end
|
|
538
576
|
|
|
539
577
|
specify "should support sql array accesses via sql_subscript" do
|
|
@@ -546,21 +584,33 @@ describe "Symbol" do
|
|
|
546
584
|
specify "should support cast_numeric and cast_string" do
|
|
547
585
|
x = :abc.cast_numeric
|
|
548
586
|
x.should be_a_kind_of(Sequel::SQL::NumericExpression)
|
|
549
|
-
|
|
587
|
+
@ds.literal(x).should == "CAST(abc AS integer)"
|
|
550
588
|
|
|
551
589
|
x = :abc.cast_numeric(:real)
|
|
552
590
|
x.should be_a_kind_of(Sequel::SQL::NumericExpression)
|
|
553
|
-
|
|
591
|
+
@ds.literal(x).should == "CAST(abc AS real)"
|
|
554
592
|
|
|
555
593
|
x = :abc.cast_string
|
|
556
594
|
x.should be_a_kind_of(Sequel::SQL::StringExpression)
|
|
557
|
-
|
|
595
|
+
@ds.literal(x).should == "CAST(abc AS varchar(255))"
|
|
558
596
|
|
|
559
597
|
x = :abc.cast_string(:varchar)
|
|
560
598
|
x.should be_a_kind_of(Sequel::SQL::StringExpression)
|
|
561
|
-
|
|
599
|
+
@ds.literal(x).should == "CAST(abc AS varchar(255))"
|
|
562
600
|
end
|
|
563
601
|
|
|
602
|
+
specify "should support boolean methods" do
|
|
603
|
+
@ds.literal(~:x).should == "NOT x"
|
|
604
|
+
@ds.literal(:x & :y).should == "(x AND y)"
|
|
605
|
+
@ds.literal(:x | :y).should == "(x OR y)"
|
|
606
|
+
end
|
|
607
|
+
|
|
608
|
+
specify "should support complex expression methods" do
|
|
609
|
+
@ds.literal(:x.sql_boolean & 1).should == "(x AND 1)"
|
|
610
|
+
@ds.literal(:x.sql_number & :y).should == "(x & y)"
|
|
611
|
+
@ds.literal(:x.sql_string + :y).should == "(x || y)"
|
|
612
|
+
end
|
|
613
|
+
|
|
564
614
|
specify "should allow database independent types when casting" do
|
|
565
615
|
db = @ds.db
|
|
566
616
|
def db.cast_type_literal(type)
|
|
@@ -568,16 +618,16 @@ describe "Symbol" do
|
|
|
568
618
|
return :bar if type == String
|
|
569
619
|
type
|
|
570
620
|
end
|
|
571
|
-
:abc.cast(String)
|
|
572
|
-
:abc.cast(String)
|
|
573
|
-
:abc.cast_string
|
|
574
|
-
:abc.cast_string(Integer)
|
|
575
|
-
:abc.cast_numeric
|
|
576
|
-
:abc.cast_numeric(String)
|
|
621
|
+
@ds.literal(:abc.cast(String)).should == "CAST(abc AS bar)"
|
|
622
|
+
@ds.literal(:abc.cast(String)).should == "CAST(abc AS bar)"
|
|
623
|
+
@ds.literal(:abc.cast_string).should == "CAST(abc AS bar)"
|
|
624
|
+
@ds.literal(:abc.cast_string(Integer)).should == "CAST(abc AS foo)"
|
|
625
|
+
@ds.literal(:abc.cast_numeric).should == "CAST(abc AS foo)"
|
|
626
|
+
@ds.literal(:abc.cast_numeric(String)).should == "CAST(abc AS bar)"
|
|
577
627
|
end
|
|
578
628
|
|
|
579
629
|
specify "should support SQL EXTRACT function via #extract " do
|
|
580
|
-
:abc.extract(:year)
|
|
630
|
+
@ds.literal(:abc.extract(:year)).should == "extract(year FROM abc)"
|
|
581
631
|
end
|
|
582
632
|
end
|
|
583
633
|
|