File: 3.7.0.txt

package info (click to toggle)
ruby-sequel 5.63.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,408 kB
  • sloc: ruby: 113,747; makefile: 3
file content (179 lines) | stat: -rw-r--r-- 6,742 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
New Features
------------

* Sequel now has support for deleting and updating joined datasets
  on MySQL and PostgreSQL.  Previously, Sequel only supported this to
  a limited extent on Microsoft SQL Server, and support there has been
  improved as well.  
  
  This allows you to do:
  
    DB.create_table!(:a){Integer :a; Integer :d}
    DB.create_table!(:b){Integer :b; Integer :e}
    DB.create_table!(:c){Integer :c; Integer :f}
    
    # Insert some rows
    
    ds = DB.from(:a, :b).
      join(:c, :c=>:e.identifier).
      where(:d=>:b)
    ds.where(:f=>6).update(:a => 10)
    ds.where(:f=>5).delete
      
  Which will set the a column to 10 for all rows in table a, where
  an associated row in table c (through table b) has a value of 6 for
  column f.  It will delete rows from table a where an associated row
  in table c (through table b) has a value of 5 for column f.

  Sequel assumes the that first FROM table is the table being
  updated/deleted.  MySQL and Microsoft SQL Server do not require
  multiple FROM tables, but PostgreSQL does.

* Dataset #select_map, #select_order_map, and #select_hash
  convenience methods were added for quickly creating arrays and
  hashes from a dataset.
  
  select_map and select_order_map both return arrays of values for the
  column specified.  The column can be specified either via an argument
  or a block, similar to Dataset#get.  Both accept any valid objects as
  arguments.

  select_hash returns a hash.  It requires two symbol arguments, but
  can handle implicit qualifiers or aliases in the symbols.

  Neither of these methods offer any new functionality, they just cut
  down on the number of required key strokes:

    select_map(:column)       # select(:column).map(:column)
    select_order_map(:column) # select(:column).order(:column).
                              #  map(:column)
    select_hash(:key_column, :value_column)
    # select(:key_column, :value_column).
    #  to_hash(:key_column, :value_column)

* The NULL, NOTNULL, TRUE, SQLTRUE, FALSE, and SQLFALSE constants
  were added to Sequel::SQL::Constants.  This allows you to do:
  
    include Sequel::SQL::Constants
    DB[:table].where(:a=>'1', :b=>NOTNULL)
    
  Previously, the shortest way to do this was:

    DB[:table].where(:a=>'1').exclude(:b=>nil)
    
  It may make the code more descriptive:

    DB[:table].where(:b=>NULL)
    # compared to
    DB[:table].where(:b=>nil)

  This gives the option to use SQL terminology instead of ruby
  terminology.

  The other advantage of using the constants it that they handle
  operators and methods like other Sequel::SQL objects:

    NULL & SQLFALSE # BooleanExpression => "(NULL AND FALSE)"
    nil & false     # false

    NULL + :a       # NumericExpression => "(NULL + a)"
    nil + :a        # raises NoMethodError
    NULL.sql_string + :a  # StringExpression => "(NULL || a)"
    NULL.as(:b)     # AliasedExpression => "NULL AS b"

  For complex systems that want to represent SQL boolean objects
  in ruby (where you don't know exactly how they'll be used), using
  the constants is recommended.

  In order not to be too verbose, including Sequel::SQL::Constants
  is recommended.  It's not done by default, but you can still
  reference the constants under the main Sequel module by default
  (e.g. Sequel::NULL).
  
* The validates_unique method in the validation_helpers plugin now
  supports an :only_if_modified option, which should speed up the
  common case where the unique attribute is not modified for an
  existing record.  It's not on by default, since it's possible the
  database could be changed between retrieving the model object and
  updating it.
  
* The Dataset #union, #intersect, and #except methods now accept an
  :alias option which is used as the alias for the returned dataset.
  
    DB[:table].union(DB[:old_table], :alias=>:table)

* Model#destroy now supports a :transaction option, similar to
  Model#save.

* The shared Oracle adapter now supports Dataset#sequence for
  returning autogenerated primary key values on insert from a
  related sequence.

  This makes Oracle work correctly when using models, with
  something like the following:
  
    class Album < Sequel::Model
      set_dataset dataset.sequence(:seq_albums_id)
    end
    
  You currently need to call Dataset#sequence in every model
  class where the underlying table uses a sequence to generate
  primary key values.

Other Improvements
------------------

* In Model #save and #destroy when using transactions and when
  raise_on_save_failure is false, ensure that transactions are rolled
  back if a before hook returns false.

* Dataset#group_and_count now handles arguments other than Symbols.
  A previous change to the method raised an exception if a Symbol was
  not provided.  It also handles AliasedExpressions natively, so the
  following works correctly:
  
    DB[:table].group_and_count(:column.as(:alias))

* Sequel no longer uses native autoreconnection in the mysql adapter.
  Native autoreconnection has problems with prepared statements,
  where a new native connection is used behind Sequel's back, so
  Sequel thinks the prepared statement has already been defined on
  the connection, when it fact it hasn't.  Any other changes that
  affect the state of the connection will be lost when native
  autoreconnection is used as well.

  Sequel's connection pool already handles reconnection if it detects
  a disconnection.  This commit also adds an additional exception
  message to recognize as a disconnect.  If there other exception
  messages related to disconnects, please post them on the Sequel
  mailing list.

* The schema_dumper plugin now specifies the :type option for primary
  key if it isn't Integer.

* On PostgreSQL, the bigserial type is used if :type=>Bignum is
  given as an option to primary key.  This makes it operate more
  similarly to other adapters that support autoincrementing 64-bit
  integer primary keys.
  
* The native mysql adapter will now attempt to load options in the
  [client] section of the my.cnf file.

* The rake spec tasks for the project now work correctly with RSpec
  1.2.9.

Backwards Compatibility
-----------------------

* Dataset::GET_ERROR_MSG and Dataset::MAP_ERROR_MSG constants were
  removed.  Both were replaced with Dataset::ARG_BLOCK_ERROR_MSG.
  
* The behavior of the Model#save_failure private instance method was
  modified.  It now always raises an exception, and validation
  failures no longer call it.

* The internals of how autogenerated primary key metadata is stored
  when creating tables on PostgreSQL has been modified.

* The native MySQL adapter no longer sets the OPT_LOCAL_INFILE option
  to "client" on the native connection.