sequel 2.12.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/CHANGELOG +62 -0
  2. data/README.rdoc +3 -3
  3. data/Rakefile +7 -0
  4. data/doc/advanced_associations.rdoc +44 -0
  5. data/doc/release_notes/3.0.0.txt +221 -0
  6. data/lib/sequel/adapters/amalgalite.rb +208 -0
  7. data/lib/sequel/adapters/db2.rb +3 -0
  8. data/lib/sequel/adapters/dbi.rb +9 -0
  9. data/lib/sequel/adapters/do.rb +0 -4
  10. data/lib/sequel/adapters/firebird.rb +16 -18
  11. data/lib/sequel/adapters/informix.rb +5 -3
  12. data/lib/sequel/adapters/jdbc.rb +24 -20
  13. data/lib/sequel/adapters/jdbc/h2.rb +15 -4
  14. data/lib/sequel/adapters/mysql.rb +4 -8
  15. data/lib/sequel/adapters/odbc.rb +0 -4
  16. data/lib/sequel/adapters/oracle.rb +0 -4
  17. data/lib/sequel/adapters/shared/mssql.rb +16 -5
  18. data/lib/sequel/adapters/shared/mysql.rb +87 -86
  19. data/lib/sequel/adapters/shared/oracle.rb +92 -3
  20. data/lib/sequel/adapters/shared/postgres.rb +85 -29
  21. data/lib/sequel/adapters/shared/progress.rb +8 -3
  22. data/lib/sequel/adapters/shared/sqlite.rb +53 -23
  23. data/lib/sequel/adapters/sqlite.rb +4 -7
  24. data/lib/sequel/adapters/utils/unsupported.rb +3 -3
  25. data/lib/sequel/connection_pool.rb +18 -25
  26. data/lib/sequel/core.rb +2 -21
  27. data/lib/sequel/database.rb +60 -44
  28. data/lib/sequel/database/schema_generator.rb +26 -31
  29. data/lib/sequel/database/schema_methods.rb +8 -3
  30. data/lib/sequel/database/schema_sql.rb +114 -28
  31. data/lib/sequel/dataset.rb +14 -41
  32. data/lib/sequel/dataset/convenience.rb +31 -54
  33. data/lib/sequel/dataset/graph.rb +7 -13
  34. data/lib/sequel/dataset/sql.rb +43 -54
  35. data/lib/sequel/extensions/inflector.rb +0 -5
  36. data/lib/sequel/extensions/schema_dumper.rb +238 -0
  37. data/lib/sequel/metaprogramming.rb +0 -20
  38. data/lib/sequel/model.rb +1 -2
  39. data/lib/sequel/model/base.rb +18 -16
  40. data/lib/sequel/model/inflections.rb +6 -9
  41. data/lib/sequel/plugins/caching.rb +0 -6
  42. data/lib/sequel/plugins/hook_class_methods.rb +1 -1
  43. data/lib/sequel/sql.rb +2 -0
  44. data/lib/sequel/version.rb +2 -2
  45. data/spec/adapters/firebird_spec.rb +35 -8
  46. data/spec/adapters/mysql_spec.rb +173 -266
  47. data/spec/adapters/oracle_spec.rb +13 -0
  48. data/spec/adapters/postgres_spec.rb +127 -227
  49. data/spec/adapters/sqlite_spec.rb +13 -171
  50. data/spec/core/connection_pool_spec.rb +15 -4
  51. data/spec/core/core_sql_spec.rb +14 -170
  52. data/spec/core/database_spec.rb +50 -132
  53. data/spec/core/dataset_spec.rb +47 -930
  54. data/spec/core/expression_filters_spec.rb +12 -0
  55. data/spec/core/schema_generator_spec.rb +37 -45
  56. data/spec/core/schema_spec.rb +26 -16
  57. data/spec/core/spec_helper.rb +0 -25
  58. data/spec/extensions/inflector_spec.rb +0 -3
  59. data/spec/extensions/schema_dumper_spec.rb +292 -0
  60. data/spec/extensions/serialization_spec.rb +9 -0
  61. data/spec/extensions/single_table_inheritance_spec.rb +6 -1
  62. data/spec/extensions/spec_helper.rb +1 -3
  63. data/spec/extensions/validation_helpers_spec.rb +4 -4
  64. data/spec/integration/database_test.rb +18 -0
  65. data/spec/integration/dataset_test.rb +112 -1
  66. data/spec/integration/eager_loader_test.rb +70 -9
  67. data/spec/integration/prepared_statement_test.rb +2 -2
  68. data/spec/integration/schema_test.rb +76 -27
  69. data/spec/integration/spec_helper.rb +0 -14
  70. data/spec/integration/transaction_test.rb +27 -0
  71. data/spec/model/associations_spec.rb +0 -36
  72. data/spec/model/base_spec.rb +18 -123
  73. data/spec/model/hooks_spec.rb +2 -235
  74. data/spec/model/inflector_spec.rb +15 -115
  75. data/spec/model/model_spec.rb +0 -120
  76. data/spec/model/plugins_spec.rb +0 -70
  77. data/spec/model/record_spec.rb +35 -93
  78. data/spec/model/spec_helper.rb +0 -27
  79. data/spec/model/validations_spec.rb +0 -931
  80. metadata +9 -14
  81. data/lib/sequel/deprecated.rb +0 -593
  82. data/lib/sequel/deprecated_migration.rb +0 -91
  83. data/lib/sequel/model/deprecated.rb +0 -204
  84. data/lib/sequel/model/deprecated_hooks.rb +0 -103
  85. data/lib/sequel/model/deprecated_inflector.rb +0 -335
  86. data/lib/sequel/model/deprecated_validations.rb +0 -388
  87. data/spec/core/core_ext_spec.rb +0 -156
  88. data/spec/core/migration_spec.rb +0 -263
  89. data/spec/core/pretty_table_spec.rb +0 -58
  90. data/spec/model/caching_spec.rb +0 -217
  91. data/spec/model/schema_spec.rb +0 -92
@@ -1,92 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "spec_helper")
2
-
3
- describe Sequel::Model, "table_exists?" do
4
-
5
- before(:each) do
6
- MODEL_DB.reset
7
- @model = Class.new(Sequel::Model(:items))
8
- end
9
-
10
- it "should get the table name and question the model's db if table_exists?" do
11
- @model.should_receive(:table_name).and_return(:items)
12
- @model.db.should_receive(:table_exists?)
13
- @model.table_exists?
14
- end
15
-
16
- end
17
-
18
- describe Sequel::Model, "create_table and schema" do
19
-
20
- before(:each) do
21
- MODEL_DB.reset
22
- deprec do
23
- @model = Class.new(Sequel::Model) do
24
- set_schema(:items) do
25
- text :name
26
- float :price, :null => false
27
- end
28
- end
29
- end
30
- end
31
-
32
- deprec_specify "should get the create table SQL list from the db and execute it line by line" do
33
- @model.create_table
34
- MODEL_DB.sqls.should == ['CREATE TABLE items (name text, price float NOT NULL)']
35
- end
36
-
37
- deprec_specify "should reload the schema from the database" do
38
- schem = {:name=>{:type=>:string}, :price=>{:type=>:float}}
39
- @model.db.should_receive(:schema).with(:items, :reload=>true).and_return(schem.to_a.sort_by{|x| x[0].to_s})
40
- @model.create_table
41
- @model.db_schema.should == schem
42
- @model.instance_variable_get(:@columns).should == [:name, :price]
43
- end
44
-
45
- deprec_specify "should return the schema generator via schema" do
46
- @model.schema.should be_a_kind_of(Sequel::Schema::Generator)
47
- end
48
-
49
- deprec_specify "should use the superclasses schema if it exists" do
50
- @submodel = Class.new(@model)
51
- @submodel.schema.should be_a_kind_of(Sequel::Schema::Generator)
52
- end
53
-
54
- deprec_specify "should return nil if no schema is present" do
55
- @model = Class.new(Sequel::Model)
56
- @model.schema.should == nil
57
- @submodel = Class.new(@model)
58
- @submodel.schema.should == nil
59
- end
60
- end
61
-
62
- describe Sequel::Model, "drop_table" do
63
-
64
- before(:each) do
65
- MODEL_DB.reset
66
- @model = Class.new(Sequel::Model(:items))
67
- end
68
-
69
- deprec_specify "should get the drop table SQL for the associated table and then execute the SQL." do
70
- @model.should_receive(:table_name).and_return(:items)
71
- @model.db.should_receive(:drop_table_sql).with(:items)
72
- @model.db.should_receive(:execute).and_return(:true)
73
- @model.drop_table
74
- end
75
-
76
- end
77
-
78
- describe Sequel::Model, "create_table!" do
79
-
80
- before(:each) do
81
- MODEL_DB.reset
82
- @model = Class.new(Sequel::Model(:items))
83
- end
84
-
85
- deprec_specify "should drop table if it exists and then create the table" do
86
- @model.should_receive(:drop_table).and_return(true)
87
- @model.should_receive(:create_table).and_return(true)
88
-
89
- @model.create_table!
90
- end
91
-
92
- end