viking-sequel 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. data/CHANGELOG +3134 -0
  2. data/COPYING +19 -0
  3. data/README.rdoc +723 -0
  4. data/Rakefile +193 -0
  5. data/bin/sequel +196 -0
  6. data/doc/advanced_associations.rdoc +644 -0
  7. data/doc/cheat_sheet.rdoc +218 -0
  8. data/doc/dataset_basics.rdoc +106 -0
  9. data/doc/dataset_filtering.rdoc +158 -0
  10. data/doc/opening_databases.rdoc +296 -0
  11. data/doc/prepared_statements.rdoc +104 -0
  12. data/doc/reflection.rdoc +84 -0
  13. data/doc/release_notes/1.0.txt +38 -0
  14. data/doc/release_notes/1.1.txt +143 -0
  15. data/doc/release_notes/1.3.txt +101 -0
  16. data/doc/release_notes/1.4.0.txt +53 -0
  17. data/doc/release_notes/1.5.0.txt +155 -0
  18. data/doc/release_notes/2.0.0.txt +298 -0
  19. data/doc/release_notes/2.1.0.txt +271 -0
  20. data/doc/release_notes/2.10.0.txt +328 -0
  21. data/doc/release_notes/2.11.0.txt +215 -0
  22. data/doc/release_notes/2.12.0.txt +534 -0
  23. data/doc/release_notes/2.2.0.txt +253 -0
  24. data/doc/release_notes/2.3.0.txt +88 -0
  25. data/doc/release_notes/2.4.0.txt +106 -0
  26. data/doc/release_notes/2.5.0.txt +137 -0
  27. data/doc/release_notes/2.6.0.txt +157 -0
  28. data/doc/release_notes/2.7.0.txt +166 -0
  29. data/doc/release_notes/2.8.0.txt +171 -0
  30. data/doc/release_notes/2.9.0.txt +97 -0
  31. data/doc/release_notes/3.0.0.txt +221 -0
  32. data/doc/release_notes/3.1.0.txt +406 -0
  33. data/doc/release_notes/3.10.0.txt +286 -0
  34. data/doc/release_notes/3.2.0.txt +268 -0
  35. data/doc/release_notes/3.3.0.txt +192 -0
  36. data/doc/release_notes/3.4.0.txt +325 -0
  37. data/doc/release_notes/3.5.0.txt +510 -0
  38. data/doc/release_notes/3.6.0.txt +366 -0
  39. data/doc/release_notes/3.7.0.txt +179 -0
  40. data/doc/release_notes/3.8.0.txt +151 -0
  41. data/doc/release_notes/3.9.0.txt +233 -0
  42. data/doc/schema.rdoc +36 -0
  43. data/doc/sharding.rdoc +113 -0
  44. data/doc/virtual_rows.rdoc +205 -0
  45. data/lib/sequel.rb +1 -0
  46. data/lib/sequel/adapters/ado.rb +90 -0
  47. data/lib/sequel/adapters/ado/mssql.rb +30 -0
  48. data/lib/sequel/adapters/amalgalite.rb +176 -0
  49. data/lib/sequel/adapters/db2.rb +139 -0
  50. data/lib/sequel/adapters/dbi.rb +113 -0
  51. data/lib/sequel/adapters/do.rb +188 -0
  52. data/lib/sequel/adapters/do/mysql.rb +49 -0
  53. data/lib/sequel/adapters/do/postgres.rb +91 -0
  54. data/lib/sequel/adapters/do/sqlite.rb +40 -0
  55. data/lib/sequel/adapters/firebird.rb +283 -0
  56. data/lib/sequel/adapters/informix.rb +77 -0
  57. data/lib/sequel/adapters/jdbc.rb +587 -0
  58. data/lib/sequel/adapters/jdbc/as400.rb +58 -0
  59. data/lib/sequel/adapters/jdbc/h2.rb +133 -0
  60. data/lib/sequel/adapters/jdbc/mssql.rb +57 -0
  61. data/lib/sequel/adapters/jdbc/mysql.rb +78 -0
  62. data/lib/sequel/adapters/jdbc/oracle.rb +50 -0
  63. data/lib/sequel/adapters/jdbc/postgresql.rb +108 -0
  64. data/lib/sequel/adapters/jdbc/sqlite.rb +55 -0
  65. data/lib/sequel/adapters/mysql.rb +421 -0
  66. data/lib/sequel/adapters/odbc.rb +143 -0
  67. data/lib/sequel/adapters/odbc/mssql.rb +42 -0
  68. data/lib/sequel/adapters/openbase.rb +64 -0
  69. data/lib/sequel/adapters/oracle.rb +131 -0
  70. data/lib/sequel/adapters/postgres.rb +504 -0
  71. data/lib/sequel/adapters/shared/mssql.rb +490 -0
  72. data/lib/sequel/adapters/shared/mysql.rb +498 -0
  73. data/lib/sequel/adapters/shared/oracle.rb +195 -0
  74. data/lib/sequel/adapters/shared/postgres.rb +830 -0
  75. data/lib/sequel/adapters/shared/progress.rb +44 -0
  76. data/lib/sequel/adapters/shared/sqlite.rb +389 -0
  77. data/lib/sequel/adapters/sqlite.rb +224 -0
  78. data/lib/sequel/adapters/utils/stored_procedures.rb +84 -0
  79. data/lib/sequel/connection_pool.rb +99 -0
  80. data/lib/sequel/connection_pool/sharded_single.rb +84 -0
  81. data/lib/sequel/connection_pool/sharded_threaded.rb +211 -0
  82. data/lib/sequel/connection_pool/single.rb +29 -0
  83. data/lib/sequel/connection_pool/threaded.rb +150 -0
  84. data/lib/sequel/core.rb +293 -0
  85. data/lib/sequel/core_sql.rb +241 -0
  86. data/lib/sequel/database.rb +1079 -0
  87. data/lib/sequel/database/schema_generator.rb +327 -0
  88. data/lib/sequel/database/schema_methods.rb +203 -0
  89. data/lib/sequel/database/schema_sql.rb +320 -0
  90. data/lib/sequel/dataset.rb +32 -0
  91. data/lib/sequel/dataset/actions.rb +441 -0
  92. data/lib/sequel/dataset/features.rb +86 -0
  93. data/lib/sequel/dataset/graph.rb +254 -0
  94. data/lib/sequel/dataset/misc.rb +119 -0
  95. data/lib/sequel/dataset/mutation.rb +64 -0
  96. data/lib/sequel/dataset/prepared_statements.rb +227 -0
  97. data/lib/sequel/dataset/query.rb +709 -0
  98. data/lib/sequel/dataset/sql.rb +996 -0
  99. data/lib/sequel/exceptions.rb +51 -0
  100. data/lib/sequel/extensions/blank.rb +43 -0
  101. data/lib/sequel/extensions/inflector.rb +242 -0
  102. data/lib/sequel/extensions/looser_typecasting.rb +21 -0
  103. data/lib/sequel/extensions/migration.rb +239 -0
  104. data/lib/sequel/extensions/named_timezones.rb +61 -0
  105. data/lib/sequel/extensions/pagination.rb +100 -0
  106. data/lib/sequel/extensions/pretty_table.rb +82 -0
  107. data/lib/sequel/extensions/query.rb +52 -0
  108. data/lib/sequel/extensions/schema_dumper.rb +271 -0
  109. data/lib/sequel/extensions/sql_expr.rb +122 -0
  110. data/lib/sequel/extensions/string_date_time.rb +46 -0
  111. data/lib/sequel/extensions/thread_local_timezones.rb +48 -0
  112. data/lib/sequel/metaprogramming.rb +9 -0
  113. data/lib/sequel/model.rb +120 -0
  114. data/lib/sequel/model/associations.rb +1514 -0
  115. data/lib/sequel/model/base.rb +1069 -0
  116. data/lib/sequel/model/default_inflections.rb +45 -0
  117. data/lib/sequel/model/errors.rb +39 -0
  118. data/lib/sequel/model/exceptions.rb +21 -0
  119. data/lib/sequel/model/inflections.rb +162 -0
  120. data/lib/sequel/model/plugins.rb +70 -0
  121. data/lib/sequel/plugins/active_model.rb +59 -0
  122. data/lib/sequel/plugins/association_dependencies.rb +103 -0
  123. data/lib/sequel/plugins/association_proxies.rb +41 -0
  124. data/lib/sequel/plugins/boolean_readers.rb +53 -0
  125. data/lib/sequel/plugins/caching.rb +141 -0
  126. data/lib/sequel/plugins/class_table_inheritance.rb +214 -0
  127. data/lib/sequel/plugins/composition.rb +138 -0
  128. data/lib/sequel/plugins/force_encoding.rb +72 -0
  129. data/lib/sequel/plugins/hook_class_methods.rb +126 -0
  130. data/lib/sequel/plugins/identity_map.rb +116 -0
  131. data/lib/sequel/plugins/instance_filters.rb +98 -0
  132. data/lib/sequel/plugins/instance_hooks.rb +57 -0
  133. data/lib/sequel/plugins/lazy_attributes.rb +77 -0
  134. data/lib/sequel/plugins/many_through_many.rb +208 -0
  135. data/lib/sequel/plugins/nested_attributes.rb +206 -0
  136. data/lib/sequel/plugins/optimistic_locking.rb +81 -0
  137. data/lib/sequel/plugins/rcte_tree.rb +281 -0
  138. data/lib/sequel/plugins/schema.rb +66 -0
  139. data/lib/sequel/plugins/serialization.rb +166 -0
  140. data/lib/sequel/plugins/single_table_inheritance.rb +74 -0
  141. data/lib/sequel/plugins/subclasses.rb +45 -0
  142. data/lib/sequel/plugins/tactical_eager_loading.rb +61 -0
  143. data/lib/sequel/plugins/timestamps.rb +87 -0
  144. data/lib/sequel/plugins/touch.rb +118 -0
  145. data/lib/sequel/plugins/typecast_on_load.rb +72 -0
  146. data/lib/sequel/plugins/validation_class_methods.rb +405 -0
  147. data/lib/sequel/plugins/validation_helpers.rb +223 -0
  148. data/lib/sequel/sql.rb +1020 -0
  149. data/lib/sequel/timezones.rb +161 -0
  150. data/lib/sequel/version.rb +12 -0
  151. data/lib/sequel_core.rb +1 -0
  152. data/lib/sequel_model.rb +1 -0
  153. data/spec/adapters/firebird_spec.rb +407 -0
  154. data/spec/adapters/informix_spec.rb +97 -0
  155. data/spec/adapters/mssql_spec.rb +403 -0
  156. data/spec/adapters/mysql_spec.rb +1019 -0
  157. data/spec/adapters/oracle_spec.rb +286 -0
  158. data/spec/adapters/postgres_spec.rb +969 -0
  159. data/spec/adapters/spec_helper.rb +51 -0
  160. data/spec/adapters/sqlite_spec.rb +432 -0
  161. data/spec/core/connection_pool_spec.rb +808 -0
  162. data/spec/core/core_sql_spec.rb +417 -0
  163. data/spec/core/database_spec.rb +1662 -0
  164. data/spec/core/dataset_spec.rb +3827 -0
  165. data/spec/core/expression_filters_spec.rb +595 -0
  166. data/spec/core/object_graph_spec.rb +296 -0
  167. data/spec/core/schema_generator_spec.rb +159 -0
  168. data/spec/core/schema_spec.rb +830 -0
  169. data/spec/core/spec_helper.rb +56 -0
  170. data/spec/core/version_spec.rb +7 -0
  171. data/spec/extensions/active_model_spec.rb +76 -0
  172. data/spec/extensions/association_dependencies_spec.rb +127 -0
  173. data/spec/extensions/association_proxies_spec.rb +50 -0
  174. data/spec/extensions/blank_spec.rb +67 -0
  175. data/spec/extensions/boolean_readers_spec.rb +92 -0
  176. data/spec/extensions/caching_spec.rb +250 -0
  177. data/spec/extensions/class_table_inheritance_spec.rb +252 -0
  178. data/spec/extensions/composition_spec.rb +194 -0
  179. data/spec/extensions/force_encoding_spec.rb +117 -0
  180. data/spec/extensions/hook_class_methods_spec.rb +470 -0
  181. data/spec/extensions/identity_map_spec.rb +202 -0
  182. data/spec/extensions/inflector_spec.rb +181 -0
  183. data/spec/extensions/instance_filters_spec.rb +55 -0
  184. data/spec/extensions/instance_hooks_spec.rb +133 -0
  185. data/spec/extensions/lazy_attributes_spec.rb +153 -0
  186. data/spec/extensions/looser_typecasting_spec.rb +39 -0
  187. data/spec/extensions/many_through_many_spec.rb +884 -0
  188. data/spec/extensions/migration_spec.rb +332 -0
  189. data/spec/extensions/named_timezones_spec.rb +72 -0
  190. data/spec/extensions/nested_attributes_spec.rb +396 -0
  191. data/spec/extensions/optimistic_locking_spec.rb +100 -0
  192. data/spec/extensions/pagination_spec.rb +99 -0
  193. data/spec/extensions/pretty_table_spec.rb +91 -0
  194. data/spec/extensions/query_spec.rb +85 -0
  195. data/spec/extensions/rcte_tree_spec.rb +205 -0
  196. data/spec/extensions/schema_dumper_spec.rb +357 -0
  197. data/spec/extensions/schema_spec.rb +127 -0
  198. data/spec/extensions/serialization_spec.rb +209 -0
  199. data/spec/extensions/single_table_inheritance_spec.rb +96 -0
  200. data/spec/extensions/spec_helper.rb +91 -0
  201. data/spec/extensions/sql_expr_spec.rb +89 -0
  202. data/spec/extensions/string_date_time_spec.rb +93 -0
  203. data/spec/extensions/subclasses_spec.rb +52 -0
  204. data/spec/extensions/tactical_eager_loading_spec.rb +65 -0
  205. data/spec/extensions/thread_local_timezones_spec.rb +45 -0
  206. data/spec/extensions/timestamps_spec.rb +150 -0
  207. data/spec/extensions/touch_spec.rb +155 -0
  208. data/spec/extensions/typecast_on_load_spec.rb +69 -0
  209. data/spec/extensions/validation_class_methods_spec.rb +984 -0
  210. data/spec/extensions/validation_helpers_spec.rb +438 -0
  211. data/spec/integration/associations_test.rb +281 -0
  212. data/spec/integration/database_test.rb +26 -0
  213. data/spec/integration/dataset_test.rb +963 -0
  214. data/spec/integration/eager_loader_test.rb +734 -0
  215. data/spec/integration/model_test.rb +130 -0
  216. data/spec/integration/plugin_test.rb +814 -0
  217. data/spec/integration/prepared_statement_test.rb +213 -0
  218. data/spec/integration/schema_test.rb +361 -0
  219. data/spec/integration/spec_helper.rb +73 -0
  220. data/spec/integration/timezone_test.rb +55 -0
  221. data/spec/integration/transaction_test.rb +122 -0
  222. data/spec/integration/type_test.rb +96 -0
  223. data/spec/model/association_reflection_spec.rb +175 -0
  224. data/spec/model/associations_spec.rb +2633 -0
  225. data/spec/model/base_spec.rb +418 -0
  226. data/spec/model/dataset_methods_spec.rb +78 -0
  227. data/spec/model/eager_loading_spec.rb +1391 -0
  228. data/spec/model/hooks_spec.rb +240 -0
  229. data/spec/model/inflector_spec.rb +26 -0
  230. data/spec/model/model_spec.rb +593 -0
  231. data/spec/model/plugins_spec.rb +236 -0
  232. data/spec/model/record_spec.rb +1500 -0
  233. data/spec/model/spec_helper.rb +97 -0
  234. data/spec/model/validations_spec.rb +153 -0
  235. data/spec/rcov.opts +6 -0
  236. data/spec/spec_config.rb.example +10 -0
  237. metadata +346 -0
@@ -0,0 +1,38 @@
1
+ === New code organization
2
+
3
+ Sequel is now divided into two parts: sequel_core and sequel_model.
4
+ These two parts are distributed as two separate gems. The sequel gem
5
+ bundles sequel_core and sequel_model together. If you don't use
6
+ Sequel::Model in your code, you can just install and use sequel_core.
7
+
8
+ === New model hooks implementation
9
+
10
+ The hooks implementation have been rewritten from scratch, is much
11
+ more robust and offers a few new features:
12
+
13
+ * More ways to define hooks: hooks can now be defined by supplying a
14
+ block or a method name, or by overriding the hook instance method.
15
+
16
+ * Inheritable hooks: Hooks can now be inherited, which means that you
17
+ can define general hooks in a model superclass, and use them in
18
+ subclasses. You can also define global hooks on Sequel::Model that
19
+ will be invoked for all model classes.
20
+
21
+ * Hook chains can be broken by returning false from within the hook.
22
+
23
+ * New after_initialize hook, invoked after instance initialization.
24
+
25
+ * The hook invocation order can no longer be changed. Hooks are
26
+ invoked in order of definition, from the top of the class hierarchy
27
+ (that is, from Sequel::Model) down to the specific class.
28
+
29
+ === Miscellanea
30
+
31
+ * Removed deprecated adapter stubs, and all other deprecations in both
32
+ sequel_core and sequel_model.
33
+
34
+ * Fixed String#to_time to raise error correctly for invalid time
35
+ stamps.
36
+
37
+ * Fixed error behavior when parse_tree or ruby2ruby are not available.
38
+
@@ -0,0 +1,143 @@
1
+ === DRY Sequel models
2
+
3
+ With the new Sequel release you no longer need to explicitly specify
4
+ the table
5
+ name for each model class, assuming your model name is the singular of
6
+ the
7
+ table name (just like in ActiveRecord or DataMapper):
8
+
9
+ class UglyBug < Sequel::Model
10
+ end
11
+
12
+ UglyBug.table_name #=> :ugly_bugs
13
+
14
+ === New model validations and support for virtual attributes
15
+
16
+ Sequel model now include validation functionality which largly follows
17
+ the
18
+ validations offered in ActiveRecord. Validations can be checked
19
+ anytime by
20
+ calling Model#valid?, with validation errors accessible through
21
+ Model#errors:
22
+
23
+ class Item < Sequel::Model
24
+ validates_presence_of :name
25
+ end
26
+
27
+ my_item = Item.new
28
+ my_item.valid? #=> false
29
+ my_item.errors.full_messages #=> ["name is not present"]
30
+
31
+ The Model#save method has been changed to check for validity before
32
+ saving. If
33
+ the model instance is not valid, the #save method returns false
34
+ without saving
35
+ the instance. You can also bypass the validity test by calling
36
+ Model#save!
37
+ instead.
38
+
39
+ Model classes also now support virtual attributes, letting you assign
40
+ values to
41
+ any attribute (virtual or persistent) at initialization time:
42
+
43
+ class User < Sequel::Model
44
+ attr_accessor :password
45
+ end
46
+
47
+ u = User.new(:password => 'blah', ...)
48
+ u.password #=> 'blah'
49
+
50
+ Also, virtual attributes can be validated just like persistent
51
+ attributes.
52
+
53
+ === Other changes (long list!)
54
+
55
+ * Added Model#reload as alias to Model#refresh.
56
+
57
+ * Changed Model.create to accept a block (#126).
58
+
59
+ * Fixed Model#initialize to accept nil values (#115).
60
+
61
+ * Added Model#update_with_params method with support for virtual
62
+ attributes and auto-filtering of unrelated parameters, and changed
63
+ Model.create_with_params to support virtual attributes (#128).
64
+
65
+ * Fixed Model.dataset to correctly set the dataset if using implicit
66
+ naming or inheriting the superclass dataset (thanks celldee).
67
+
68
+ * Finalized support for virtual attributes.
69
+
70
+ * Fixed Model#set to work with string keys (#143).
71
+
72
+ * Fixed Model.create to correctly initialize instances marked as new
73
+ (#135).
74
+
75
+ * Fixed Model#initialize to convert string keys into symbol keys. This
76
+ also fixes problem with validating objects initialized with string
77
+ keys (#136).
78
+
79
+ * Added Dataset#table_exists? convenience method.
80
+
81
+ * Changed Dataset#group_and_count to accept multiple columns (#134).
82
+
83
+ * Added Dataset#select_all method.
84
+
85
+ * Added Dataset#select_more, Dataset#order_more methods (#129).
86
+
87
+ * Fixed Dataset#count to work correctly for grouped datasets (#144).
88
+
89
+ * Fixed joining datasets using aliased tables (#140).
90
+
91
+ * Added support for UNSIGNED constraint, used in MySQL? (#127).
92
+
93
+ * Implemented constraint definitions inside Database#create_table.
94
+
95
+ * Enhanced Database.connect to accept options with string keys, so it
96
+ can now accept options loaded from YAML files. Database.connect also
97
+ automatically converts :username option into :user for compatibility
98
+ with existing YAML configuration files for AR and DataMapper.
99
+
100
+ * Changed ODBC::Database to support connection using driver and
101
+ database name, also added support for untitled columns in
102
+ ODBC::Dataset (thanks Leonid Borisenko).
103
+
104
+ * Changed MySQL adapter to support specifying socket option.
105
+
106
+ * Fixed MySQL adapter to correctly format foreign key definitions
107
+ (#123).
108
+
109
+ * Changed MySQL::Dataset to allow HAVING clause on ungrouped datasets,
110
+ and put HAVING clause before ORDER BY clause (#133).
111
+
112
+ * Changed mysql adapter to default to localhost if :host option is not
113
+ specified (#114).
114
+
115
+ * Added String#to_date. Updated mysql adapter to use String#to_date
116
+ for mysql date types (thanks drfreeze).
117
+
118
+ * Fixed postgres adapter to define PGconn#async_exec as alias to #exec
119
+ if not defined (for pure-ruby postgres driver).
120
+
121
+ * Changed postgres adapter to quote column references using double
122
+ quotes.
123
+
124
+ * Applied patch for oracle adapter: fix behavior of limit and offset,
125
+ transactions, #table_exists?, #tables and additional specs (thanks
126
+ Liming Lian #122).
127
+
128
+ * Added support additional field types in postgresql adapter (#146).
129
+
130
+ * Added support for date field types in postgresql adapter (#145).
131
+
132
+ * Added support for limiting and paginating datasets with fixed SQL,
133
+ e.g. using Database#fetch.
134
+
135
+ * Added new Dataset#from_self method that returns a dataset selecting
136
+ from the original dataset.
137
+
138
+ * Allow for additional filters on a grouped dataset (#119 and #120)
139
+
140
+ * Refactored Sequelizer to use Proc#to_sexp (method provided by r2r).
141
+
142
+ * Fixed bin/sequel to require sequel_model if available.
143
+
@@ -0,0 +1,101 @@
1
+ === Better model associations
2
+
3
+ The latest release of sequel_model includes a new associations
4
+ functionality written by Jeremy Evans which replaces the old relations
5
+ code in previous versions. Please note that this version is not
6
+ completely backward-compatible and you should therefore upgrade with
7
+ caution.
8
+
9
+ The new implementation supports three kinds of relations: one_to_many,
10
+ many_to_one and many_to_many, which correspond to has_many, belongs_to
11
+ and has_and_belongs_to_many relations in ActiveRecord. In fact, the
12
+ new implementation includes aliases for ActiveRecord assocation macros
13
+ and is basically compatible with ActiveRecord conventions. It also
14
+ supports DRY implicit class name references. Here's a simple example:
15
+
16
+ class Author < Sequel::Model
17
+ has_many :books # equivalent to one_to_many
18
+ end
19
+
20
+ class Book < Sequel::Model
21
+ belongs_to :author # equivalent to many_to_one
22
+ has_and_belongs_to_many :categories # equivalent to many_to_many
23
+ end
24
+
25
+ class Category < Sequel::Model
26
+ has_and_belongs_to_many :books
27
+ end
28
+
29
+ These macros will create the following methods:
30
+
31
+ * Author#books, Author#add_book, Author#remove_book
32
+ * Book#author, Book#categories, Book#add_category,
33
+ Book#remove_category
34
+ * Category#books, Category#add_book, Category#remove_book
35
+
36
+ Unlike ActiveRecord, one_to_many and many_to_many association methods
37
+ return a dataset:
38
+
39
+ a = Author[1234]
40
+ a.books.sql #=> 'SELECT * FROM books WHERE (author_id = 1234)'
41
+
42
+ You can also tell Sequel to cache the association result set and
43
+ return it as an array:
44
+
45
+ class Author < Sequel::Model
46
+ has_many :books, :cache => true
47
+ end
48
+
49
+ Author[1234].books.class #=> Array
50
+
51
+ You can of course bypass the defaults and specify class names and key
52
+ names:
53
+
54
+ class Node < Sequel::Model
55
+ belongs_to :parent, :class => Node
56
+ belongs_to :session, :key => :producer_id
57
+ end
58
+
59
+ Another useful option is :order, which sets the order for the
60
+ association dataset:
61
+
62
+ class Author < Sequel::Model
63
+ has_many :books, :order => :title
64
+ end
65
+
66
+ Author[1234].books.sql #=> 'SELECT * FROM books WHERE (author_id =
67
+ 1234) ORDER BY title'
68
+
69
+ More information about associations can be found in the Sequel
70
+ documentation.
71
+
72
+ === Other changes
73
+
74
+ * Added configuration file for running specs (#186).
75
+
76
+ * Changed Database#drop_index to accept fixed arity (#173).
77
+
78
+ * Changed column definition sql to put UNSIGNED constraint before
79
+ unique in order to satisfy MySQL (#171).
80
+
81
+ * Enhanced MySQL adapter to support load data local infile_, added
82
+ compress option for mysql connection by default (#172).
83
+
84
+ * Fixed bug when inserting hashes in array tuples mode.
85
+
86
+ * Changed SQLite adapter to catch RuntimeError raised when executing a
87
+ statement and raise Error::InvalidStatement with the offending SQL and
88
+ error message (#188).
89
+
90
+ * Fixed Dataset#reverse to not raise for unordered dataset (#189).
91
+
92
+ * Added Dataset#unordered method and changed #order to remove order if
93
+ nil is specified (#190).
94
+
95
+ * Fixed reversing order of ASC expression (#164).
96
+
97
+ * Added support for :null => true option when defining table columns
98
+ (#192).
99
+
100
+ * Fixed Symbol#method_missing to accept variable arity (#185).
101
+
@@ -0,0 +1,53 @@
1
+ Eager loading for all types of associations:
2
+
3
+ Artist.eager(:albums).all
4
+ Album.eager(:artist, :genre, :tracks).all
5
+ Album.eager(:artist).eager(:genre).eager(:tracks).all
6
+ Album.filter(:year=>2008).eager(:artist).all
7
+
8
+ Eager loading supports cascading to an unlimited depth, and doesn't have
9
+ any aliasing issues:
10
+
11
+ Artist.eager(:albums=>:tracks).all
12
+ Artist.eager(:albums=>{:tracks=>:genre}).all
13
+
14
+ Unfortunately, eager loading comes at the expense of a small amount of
15
+ backward compatibility. If you were using uncached associations (the
16
+ default in sequel_model 0.5), they no longer work the same way. Now,
17
+ all associations act as if :cache=>true (which is now set for all
18
+ associations, so if you wrote a tool that worked with both cached and
19
+ uncached associations, it should still work).
20
+
21
+ One to many associations now populate the corresponding many to one
22
+ instance variable (even when eagerly loaded):
23
+
24
+ # Assuming: Album.one_to_many :tracks
25
+ album = Album.first
26
+ # This following code is only one query,
27
+ # not a query for the album and one for each track
28
+ album.tracks.each{|t| puts t.album.name}
29
+
30
+ ActiveRecord style has_many :through associations are now supported via
31
+ many_to_many. many_to_many will no longer select the entire result set,
32
+ just the columns of the associated table (and not the join table), so it
33
+ works for both has_and_belongs_to_many (simple join table) and has_many
34
+ :through (join table model) scenarios. If you want to include all or
35
+ part of the join table attributes, see the :select option for
36
+ many_to_many associations.
37
+
38
+ We reduced the number of gems from three (sequel, sequel_core,
39
+ sequel_model) to two (sequel, sequel_core). Basically, sequel_model is
40
+ now just sequel, and the old sequel gem metapackage is no longer. There
41
+ isn't a reason to have a gem metapackage for two gems when one
42
+ (sequel_model) depends on the other (sequel_core). This required a
43
+ version bump for the model part of sequel from 0.5.0.2 to 1.4.0 (since
44
+ the previous sequel gem version was 1.3).
45
+
46
+ Sequel 1.4.0 has fixes for 11 trackers issues, including fixes to the
47
+ MySQL and PostgreSQL adapters.
48
+
49
+ We have switched the source control repository for Sequel from Google
50
+ Code (which uses subversion) to github (which uses git). If you would
51
+ like to contribute to Sequel, please fork the github repository, make
52
+ your changes, and send a pull request. As before, posting patches on
53
+ the Google Code issue tracker is fine as well.
@@ -0,0 +1,155 @@
1
+ You can now graph a dataset and have the result split into component
2
+ tables:
3
+
4
+ DB[:artists].graph(:albums, :artist_id=>:id).first
5
+ # => {:artists=>{:id=>artists.id, :name=>artists.name}, \
6
+ # :albums=>{:id=>albums.id, :name=>albums.name,
7
+ :artist_id=>albums.artist_id}}
8
+
9
+ This aliases columns if necessary so they don't stomp on each other,
10
+ which
11
+ is what usually happens if you just join the tables:
12
+
13
+ DB[:artists].left_outer_join(:albums, :artist_id=>:id).first
14
+ # => {:id=>(albums.id||artists.id),
15
+ :name=>(albums.name||artist.names), \
16
+ :artist_id=>albums.artist_id}
17
+
18
+ Models can use graph as well, in which case the values will be model
19
+ objects:
20
+
21
+ Artist.graph(Album, :artist_id=>:id)
22
+ # => {:artists=>#<Artist...>, :albums=>#<Album...>}
23
+
24
+ Models can now eager load via .eager_graph, which will load all the
25
+ results
26
+ and all associations in a single query. This is necessary if you want
27
+ to
28
+ filter on columns in associated tables. It works exactly the same way
29
+ as
30
+ .eager, and supports cascading of associations as well:
31
+
32
+ # Artist.one_to_many :albums
33
+ # Album.one_to_many :tracks
34
+ # Track.many_to_one :genre
35
+ Artist.eager_graph(:albums=>{:tracks=>:genre}).filter( \
36
+ :tracks_name=>"Firewire").all
37
+
38
+ This will give you all artists have have an album with a track named
39
+ "Firewire", and calling .albums on one of those artists will only return
40
+ albums that have a track named "Firewire", and calling .tracks on one of
41
+ those albums will return only the track(s) named "Firewire".
42
+
43
+ You can use set_graph_aliases to select specific columns:
44
+
45
+ DB[:artists].graph(:albums, :artist_id=>:id).set_graph_aliases( \
46
+ :artist_name=>[:artists, :name], :album_name=>[:albums,
47
+ :name]).first
48
+ # => {:artists=>{:name=>artists.name}, :albums=>{:name=>albums.name}}
49
+
50
+ You can use eager_graph with set_graph_aliases to have eager loading
51
+ with
52
+ control over the SELECT clause.
53
+
54
+ All associations now update their reciprocal associations whenever the
55
+ association methods are used, so you don't need to refresh the
56
+ association or model to have the reciprocal association updated:
57
+
58
+ Album.many_to_one :band
59
+ Band.one_to_many :albums
60
+
61
+ # Note that all of these associations are cached,
62
+ # so after the first access there are no additional
63
+ # database queries to fetch associated records.
64
+
65
+ # many_to_one setter adds to reciprocal association
66
+ band1.albums # => []
67
+ album1.band = band1
68
+ band1.albums # => [album1]
69
+ band2.albums # => []
70
+ album1.band = band2
71
+ band1.albums # => []
72
+ band2.albums # => [album1]
73
+ album1.band = band2
74
+ band2.albums # => [album1]
75
+ album1.band = nil
76
+ band2.albums # => []
77
+
78
+ # one_to_many add_* method sets reciprocal association
79
+ # one_to_many remove_* method removes reciprocal association
80
+ album1.band # => nil
81
+ band1.add_album(album1)
82
+ album1.band # => band1
83
+ band2.add_album(album1)
84
+ album1.band # => band2
85
+ band2.remove_album(album1)
86
+ album1.band # => nil
87
+
88
+ Post.many_to_many :tags
89
+ Tag.many_to_many :posts
90
+
91
+ # many_to_many add_* method adds to reciprocal association
92
+ # many_to_many remove_* method removes from reciprocal association
93
+ post1.tags # => []
94
+ tag1.posts # => []
95
+ tag1.add_post(post1)
96
+ post1.tags # => [tag1]
97
+ tag1.posts # => [post1]
98
+ tag1.remove_post(post1)
99
+ post1.tags # => []
100
+ tag1.posts # => []
101
+ post1.add_tag(tag1)
102
+ post1.tags # => [tag1]
103
+ tag1.posts # => [post1]
104
+ post1.remove_tag(tag1)
105
+ post1.tags # => []
106
+ tag1.posts # => []
107
+
108
+ The MySQL and PostgreSQL adapters now support index types:
109
+
110
+ index :some_column, :type => :hash # or :spatial, :full_text, :rtree,
111
+ etc.
112
+
113
+ Starting in Sequel 1.5.0, some methods are deprecated. These methods
114
+ will be
115
+ removed in Sequel 2.0.0. The deprecation framework is fairly flexible.
116
+ You
117
+ can choose where the messages get sent:
118
+
119
+ Sequel::Deprecation.deprecation_message_stream = STDERR # the default
120
+ Sequel::Deprecation.deprecation_message_stream = \
121
+ File.new('deprecation.txt', 'wb') # A file
122
+ Sequel::Deprecation.deprecation_message_stream = nil # ignore the
123
+ messages
124
+
125
+ You can even have all deprecation messages accompanied by a traceback,
126
+ so you
127
+ can see exactly where in your code you are using a deprecated method:
128
+
129
+ Sequel::Deprecation.print_tracebacks = true
130
+
131
+ All deprecation methods come with an message telling you what
132
+ alternative code
133
+ will work.
134
+
135
+ In addition to deprecating some methods, we removed the ability to have
136
+ arrays returned instead of hashes. The array code still had debugging
137
+ messages
138
+ left it in, and we are not aware of anyone using it. Hashes have been
139
+ returned
140
+ by default since Sequel 0.3.
141
+
142
+ We have also removed the Numeric date/time extensions (e.g. 3.days.ago).
143
+ The
144
+ existing extensions were incomplete, better ones are provided elsewhere,
145
+ and the extensions were not really related to Sequel's purpose.
146
+
147
+ Sequel no longer depends on ParseTree, RubyInline, or ruby2ruby. They
148
+ are
149
+ still required to use the block filters. Sequel's only gem dependency
150
+ is on
151
+ the tiny metaid.
152
+
153
+ Sequel 1.5.0 has fixes for 12 tracker issues, including fixes to the
154
+ Informix,
155
+ MySQL, ODBC, ADO, JDBC, Postgres, and SQLite adapters.