sequel 5.82.0 → 5.84.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sequel +9 -17
  3. data/lib/sequel/adapters/jdbc/derby.rb +1 -1
  4. data/lib/sequel/adapters/shared/db2.rb +1 -1
  5. data/lib/sequel/adapters/shared/mssql.rb +14 -2
  6. data/lib/sequel/adapters/shared/postgres.rb +42 -4
  7. data/lib/sequel/adapters/shared/sqlite.rb +3 -1
  8. data/lib/sequel/database/connecting.rb +1 -4
  9. data/lib/sequel/database/misc.rb +27 -7
  10. data/lib/sequel/database/schema_methods.rb +17 -1
  11. data/lib/sequel/dataset/sql.rb +13 -0
  12. data/lib/sequel/extensions/pg_json_ops.rb +328 -1
  13. data/lib/sequel/extensions/stdio_logger.rb +48 -0
  14. data/lib/sequel/extensions/string_agg.rb +15 -2
  15. data/lib/sequel/plugins/defaults_setter.rb +16 -4
  16. data/lib/sequel/plugins/optimistic_locking.rb +2 -0
  17. data/lib/sequel/sql.rb +8 -5
  18. data/lib/sequel/version.rb +1 -1
  19. metadata +4 -235
  20. data/CHANGELOG +0 -1377
  21. data/README.rdoc +0 -936
  22. data/doc/advanced_associations.rdoc +0 -884
  23. data/doc/association_basics.rdoc +0 -1859
  24. data/doc/bin_sequel.rdoc +0 -146
  25. data/doc/cheat_sheet.rdoc +0 -255
  26. data/doc/code_order.rdoc +0 -104
  27. data/doc/core_extensions.rdoc +0 -405
  28. data/doc/dataset_basics.rdoc +0 -96
  29. data/doc/dataset_filtering.rdoc +0 -222
  30. data/doc/extensions.rdoc +0 -77
  31. data/doc/fork_safety.rdoc +0 -84
  32. data/doc/mass_assignment.rdoc +0 -98
  33. data/doc/migration.rdoc +0 -660
  34. data/doc/model_dataset_method_design.rdoc +0 -129
  35. data/doc/model_hooks.rdoc +0 -254
  36. data/doc/model_plugins.rdoc +0 -270
  37. data/doc/mssql_stored_procedures.rdoc +0 -43
  38. data/doc/object_model.rdoc +0 -563
  39. data/doc/opening_databases.rdoc +0 -439
  40. data/doc/postgresql.rdoc +0 -611
  41. data/doc/prepared_statements.rdoc +0 -144
  42. data/doc/querying.rdoc +0 -1070
  43. data/doc/reflection.rdoc +0 -120
  44. data/doc/release_notes/5.0.0.txt +0 -159
  45. data/doc/release_notes/5.1.0.txt +0 -31
  46. data/doc/release_notes/5.10.0.txt +0 -84
  47. data/doc/release_notes/5.11.0.txt +0 -83
  48. data/doc/release_notes/5.12.0.txt +0 -141
  49. data/doc/release_notes/5.13.0.txt +0 -27
  50. data/doc/release_notes/5.14.0.txt +0 -63
  51. data/doc/release_notes/5.15.0.txt +0 -39
  52. data/doc/release_notes/5.16.0.txt +0 -110
  53. data/doc/release_notes/5.17.0.txt +0 -31
  54. data/doc/release_notes/5.18.0.txt +0 -69
  55. data/doc/release_notes/5.19.0.txt +0 -28
  56. data/doc/release_notes/5.2.0.txt +0 -33
  57. data/doc/release_notes/5.20.0.txt +0 -89
  58. data/doc/release_notes/5.21.0.txt +0 -87
  59. data/doc/release_notes/5.22.0.txt +0 -48
  60. data/doc/release_notes/5.23.0.txt +0 -56
  61. data/doc/release_notes/5.24.0.txt +0 -56
  62. data/doc/release_notes/5.25.0.txt +0 -32
  63. data/doc/release_notes/5.26.0.txt +0 -35
  64. data/doc/release_notes/5.27.0.txt +0 -21
  65. data/doc/release_notes/5.28.0.txt +0 -16
  66. data/doc/release_notes/5.29.0.txt +0 -22
  67. data/doc/release_notes/5.3.0.txt +0 -121
  68. data/doc/release_notes/5.30.0.txt +0 -20
  69. data/doc/release_notes/5.31.0.txt +0 -148
  70. data/doc/release_notes/5.32.0.txt +0 -46
  71. data/doc/release_notes/5.33.0.txt +0 -24
  72. data/doc/release_notes/5.34.0.txt +0 -40
  73. data/doc/release_notes/5.35.0.txt +0 -56
  74. data/doc/release_notes/5.36.0.txt +0 -60
  75. data/doc/release_notes/5.37.0.txt +0 -30
  76. data/doc/release_notes/5.38.0.txt +0 -28
  77. data/doc/release_notes/5.39.0.txt +0 -19
  78. data/doc/release_notes/5.4.0.txt +0 -80
  79. data/doc/release_notes/5.40.0.txt +0 -40
  80. data/doc/release_notes/5.41.0.txt +0 -25
  81. data/doc/release_notes/5.42.0.txt +0 -136
  82. data/doc/release_notes/5.43.0.txt +0 -98
  83. data/doc/release_notes/5.44.0.txt +0 -32
  84. data/doc/release_notes/5.45.0.txt +0 -34
  85. data/doc/release_notes/5.46.0.txt +0 -87
  86. data/doc/release_notes/5.47.0.txt +0 -59
  87. data/doc/release_notes/5.48.0.txt +0 -14
  88. data/doc/release_notes/5.49.0.txt +0 -59
  89. data/doc/release_notes/5.5.0.txt +0 -61
  90. data/doc/release_notes/5.50.0.txt +0 -78
  91. data/doc/release_notes/5.51.0.txt +0 -47
  92. data/doc/release_notes/5.52.0.txt +0 -87
  93. data/doc/release_notes/5.53.0.txt +0 -23
  94. data/doc/release_notes/5.54.0.txt +0 -27
  95. data/doc/release_notes/5.55.0.txt +0 -21
  96. data/doc/release_notes/5.56.0.txt +0 -51
  97. data/doc/release_notes/5.57.0.txt +0 -23
  98. data/doc/release_notes/5.58.0.txt +0 -31
  99. data/doc/release_notes/5.59.0.txt +0 -73
  100. data/doc/release_notes/5.6.0.txt +0 -31
  101. data/doc/release_notes/5.60.0.txt +0 -22
  102. data/doc/release_notes/5.61.0.txt +0 -43
  103. data/doc/release_notes/5.62.0.txt +0 -132
  104. data/doc/release_notes/5.63.0.txt +0 -33
  105. data/doc/release_notes/5.64.0.txt +0 -50
  106. data/doc/release_notes/5.65.0.txt +0 -21
  107. data/doc/release_notes/5.66.0.txt +0 -24
  108. data/doc/release_notes/5.67.0.txt +0 -32
  109. data/doc/release_notes/5.68.0.txt +0 -61
  110. data/doc/release_notes/5.69.0.txt +0 -26
  111. data/doc/release_notes/5.7.0.txt +0 -108
  112. data/doc/release_notes/5.70.0.txt +0 -35
  113. data/doc/release_notes/5.71.0.txt +0 -21
  114. data/doc/release_notes/5.72.0.txt +0 -33
  115. data/doc/release_notes/5.73.0.txt +0 -66
  116. data/doc/release_notes/5.74.0.txt +0 -45
  117. data/doc/release_notes/5.75.0.txt +0 -35
  118. data/doc/release_notes/5.76.0.txt +0 -86
  119. data/doc/release_notes/5.77.0.txt +0 -63
  120. data/doc/release_notes/5.78.0.txt +0 -67
  121. data/doc/release_notes/5.79.0.txt +0 -28
  122. data/doc/release_notes/5.8.0.txt +0 -170
  123. data/doc/release_notes/5.80.0.txt +0 -40
  124. data/doc/release_notes/5.81.0.txt +0 -31
  125. data/doc/release_notes/5.82.0.txt +0 -61
  126. data/doc/release_notes/5.9.0.txt +0 -99
  127. data/doc/schema_modification.rdoc +0 -679
  128. data/doc/security.rdoc +0 -443
  129. data/doc/sharding.rdoc +0 -286
  130. data/doc/sql.rdoc +0 -648
  131. data/doc/testing.rdoc +0 -204
  132. data/doc/thread_safety.rdoc +0 -15
  133. data/doc/transactions.rdoc +0 -250
  134. data/doc/validations.rdoc +0 -558
  135. data/doc/virtual_rows.rdoc +0 -265
@@ -1,144 +0,0 @@
1
- = Prepared Statements and Bound Variables
2
-
3
- Sequel has support for prepared statements and bound variables. No matter which
4
- database you are using, the Sequel prepared statement/bound variable API remains
5
- the same. There is native support for prepared statements/bound variables on
6
- the following adapters:
7
-
8
- * ibmdb (prepared statements only)
9
- * jdbc
10
- * mysql (server prepared statements using literalized connection variables)
11
- * mysql2 (full support on 0.4+, otherwise server prepared statements using literalized connection variables)
12
- * oracle (requires type specifiers for nil/NULL values)
13
- * postgres (when using the pg driver)
14
- * sqlite
15
- * tinytds
16
-
17
- Support on other adapters is emulated.
18
-
19
- You can use the prepared_statements model plugin to automatically use prepared
20
- statements for some common model actions such as saving or deleting a model
21
- instance, or looking up a model based on a primary key.
22
-
23
- == Placeholders
24
-
25
- Generally, when using prepared statements (and certainly when using bound
26
- variables), you need to put placeholders in your SQL to indicate where you
27
- want your bound arguments to appear. Database support and syntax vary
28
- significantly for placeholders (e.g. :name, $1, ?). Sequel abstracts all of
29
- that and allows you to specify placeholders by using the :$name format for
30
- placeholders, e.g.:
31
-
32
- ds = DB[:items].where(name: :$n)
33
-
34
- You can use these placeholders in most places where you can use the value
35
- directly. For example, if you want to use placeholders while also using
36
- raw SQL, you can do:
37
-
38
- ds = DB["SELECT * FROM items WHERE name = ?", :$n]
39
-
40
- == Bound Variables
41
-
42
- Using bound variables for this query is simple:
43
-
44
- ds.call(:select, n: 'Jim')
45
-
46
- This will do the equivalent of selecting records that have the name 'Jim'. It
47
- returns all records, and can take a block that is passed to <tt>Dataset#all</tt>.
48
-
49
- Deleting or returning the first record works similarly:
50
-
51
- ds.call(:first, n: 'Jim') # First record with name 'Jim'
52
- ds.call(:delete, n: 'Jim') # Delete records with name 'Jim'
53
-
54
- For inserting/updating records, you should also specify a value hash, which
55
- may itself contain placeholders:
56
-
57
- # Insert record with 'Jim', note that the previous filter is ignored
58
- ds.call(:insert, {n: 'Jim'}, name: :$n)
59
- # Change name to 'Bob' for all records with name of 'Jim'
60
- ds.call(:update, {n: 'Jim', new_n: 'Bob'}, name: :$new_n)
61
-
62
- == Prepared Statements
63
-
64
- Prepared statement support is similar to bound variable support, but you
65
- use <tt>Dataset#prepare</tt> with a name, and <tt>Dataset#call</tt> or <tt>Database#call</tt> later with the values:
66
-
67
- ds = DB[:items].where(name: :$n)
68
- ps = ds.prepare(:select, :select_by_name)
69
-
70
- ps.call(n: 'Jim')
71
- DB.call(:select_by_name, n: 'Jim') # same
72
-
73
- The <tt>Dataset#prepare</tt> method returns a prepared statement, and also stores a
74
- copy of the prepared statement in the database for later use. For insert
75
- and update queries, the hash to insert/update is passed to +prepare+:
76
-
77
- ps1 = DB[:items].prepare(:insert, :insert_with_name, name: :$n)
78
-
79
- ps1.call(n: 'Jim')
80
- DB.call(:insert_with_name, n: 'Jim') # same
81
-
82
- ds = DB[:items].where(name: :$n)
83
- ps2 = ds.prepare(:update, :update_name, name: :$new_n)
84
-
85
- ps2.call(n: 'Jim', new_n: 'Bob')
86
- DB.call(:update_name, n: 'Jim', new_n: 'Bob') # same
87
-
88
- == Implementation Issues
89
-
90
- Currently, creating a prepared statement uses Object#extend, which can hurt
91
- performance. For high performance applications, it's recommended to create
92
- all of your prepared statements upon application initialization, and not
93
- to create prepared statements dynamically at runtime.
94
-
95
- == Database support
96
-
97
- === PostgreSQL
98
-
99
- If you are using the postgres-pr driver, PostgreSQL uses the
100
- default emulated support. If you are using ruby-pg, there is native support
101
- for both prepared statements and bound variables. Prepared statements are
102
- always server side.
103
-
104
- === SQLite
105
-
106
- SQLite supports both prepared statements and bound variables.
107
-
108
- === MySQL/Mysql2
109
-
110
- The MySQL and Mysql2 <0.4 ruby drivers do not support bound variables, so the bound
111
- variable methods are emulated. It uses server side prepared statements.
112
-
113
- Mysql2 0.4+ supports both prepared statements and bound variables.
114
-
115
- === JDBC
116
-
117
- JDBC supports both prepared statements and bound variables. Whether these
118
- are server side or client side depends on the JDBC driver. For PostgreSQL
119
- over JDBC, you can add the prepareThreshold=N parameter to the connection
120
- string, which will use a server side prepared statement after N calls to
121
- the prepared statement.
122
-
123
- === TinyTDS
124
-
125
- Uses the sp_executesql stored procedure with bound variables, since
126
- Microsoft SQL Server doesn't support true prepared statements.
127
-
128
- === IBM_DB
129
-
130
- DB2 supports both prepared statements and bound variables.
131
-
132
- === Oracle
133
-
134
- Oracle supports both prepared statements and bound variables. Prepared
135
- statements (OCI8::Cursor objects) are cached per connection. If you
136
- ever plan to use a nil/NULL value as a bound variable/prepared statement
137
- value, you must specify the type in the placeholder using a __* suffix.
138
- You can use any of the schema types that Sequel supports, such as
139
- :$name__string or :$num__integer. Using blobs as bound variables is
140
- not currently supported.
141
-
142
- === All Others
143
-
144
- Support is emulated.