sequel 5.80.0 → 5.92.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.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sequel +9 -4
  3. data/lib/sequel/adapters/ado.rb +1 -1
  4. data/lib/sequel/adapters/ibmdb.rb +1 -0
  5. data/lib/sequel/adapters/jdbc/db2.rb +2 -2
  6. data/lib/sequel/adapters/jdbc/derby.rb +3 -3
  7. data/lib/sequel/adapters/jdbc/h2.rb +2 -2
  8. data/lib/sequel/adapters/jdbc/hsqldb.rb +2 -2
  9. data/lib/sequel/adapters/jdbc/jtds.rb +2 -2
  10. data/lib/sequel/adapters/jdbc/mysql.rb +1 -1
  11. data/lib/sequel/adapters/jdbc/oracle.rb +5 -5
  12. data/lib/sequel/adapters/jdbc/postgresql.rb +5 -5
  13. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +6 -6
  14. data/lib/sequel/adapters/jdbc/sqlite.rb +2 -2
  15. data/lib/sequel/adapters/jdbc/sqlserver.rb +2 -2
  16. data/lib/sequel/adapters/jdbc.rb +8 -8
  17. data/lib/sequel/adapters/mysql2.rb +8 -1
  18. data/lib/sequel/adapters/shared/access.rb +1 -0
  19. data/lib/sequel/adapters/shared/db2.rb +1 -1
  20. data/lib/sequel/adapters/shared/mssql.rb +18 -5
  21. data/lib/sequel/adapters/shared/mysql.rb +8 -4
  22. data/lib/sequel/adapters/shared/oracle.rb +1 -0
  23. data/lib/sequel/adapters/shared/postgres.rb +106 -13
  24. data/lib/sequel/adapters/shared/sqlite.rb +4 -2
  25. data/lib/sequel/adapters/sqlite.rb +4 -0
  26. data/lib/sequel/adapters/trilogy.rb +1 -2
  27. data/lib/sequel/connection_pool/sharded_threaded.rb +26 -10
  28. data/lib/sequel/connection_pool/threaded.rb +26 -10
  29. data/lib/sequel/connection_pool.rb +2 -2
  30. data/lib/sequel/core.rb +15 -0
  31. data/lib/sequel/database/connecting.rb +20 -26
  32. data/lib/sequel/database/dataset_defaults.rb +3 -3
  33. data/lib/sequel/database/misc.rb +46 -10
  34. data/lib/sequel/database/query.rb +11 -11
  35. data/lib/sequel/database/schema_generator.rb +8 -0
  36. data/lib/sequel/database/schema_methods.rb +17 -1
  37. data/lib/sequel/dataset/actions.rb +9 -1
  38. data/lib/sequel/dataset/deprecated_singleton_class_methods.rb +1 -1
  39. data/lib/sequel/dataset/prepared_statements.rb +2 -1
  40. data/lib/sequel/dataset/query.rb +9 -5
  41. data/lib/sequel/dataset/sql.rb +25 -5
  42. data/lib/sequel/extensions/caller_logging.rb +2 -0
  43. data/lib/sequel/extensions/connection_validator.rb +15 -10
  44. data/lib/sequel/extensions/dataset_run.rb +41 -0
  45. data/lib/sequel/extensions/migration.rb +23 -3
  46. data/lib/sequel/extensions/null_dataset.rb +2 -2
  47. data/lib/sequel/extensions/pg_auto_parameterize.rb +1 -1
  48. data/lib/sequel/extensions/pg_auto_parameterize_in_array.rb +93 -10
  49. data/lib/sequel/extensions/pg_enum.rb +3 -3
  50. data/lib/sequel/extensions/pg_json_ops.rb +642 -9
  51. data/lib/sequel/extensions/pg_row.rb +3 -1
  52. data/lib/sequel/extensions/pg_schema_caching.rb +90 -0
  53. data/lib/sequel/extensions/provenance.rb +2 -0
  54. data/lib/sequel/extensions/query_blocker.rb +172 -0
  55. data/lib/sequel/extensions/schema_caching.rb +24 -9
  56. data/lib/sequel/extensions/schema_dumper.rb +16 -4
  57. data/lib/sequel/extensions/sqlite_json_ops.rb +1 -1
  58. data/lib/sequel/extensions/stdio_logger.rb +48 -0
  59. data/lib/sequel/extensions/string_agg.rb +17 -4
  60. data/lib/sequel/extensions/temporarily_release_connection.rb +178 -0
  61. data/lib/sequel/extensions/virtual_row_method_block.rb +1 -0
  62. data/lib/sequel/model/associations.rb +28 -3
  63. data/lib/sequel/model/base.rb +67 -18
  64. data/lib/sequel/plugins/association_pks.rb +1 -1
  65. data/lib/sequel/plugins/column_encryption.rb +1 -1
  66. data/lib/sequel/plugins/composition.rb +1 -1
  67. data/lib/sequel/plugins/defaults_setter.rb +16 -4
  68. data/lib/sequel/plugins/enum.rb +1 -1
  69. data/lib/sequel/plugins/forbid_lazy_load.rb +14 -1
  70. data/lib/sequel/plugins/input_transformer.rb +1 -1
  71. data/lib/sequel/plugins/inspect_pk.rb +44 -0
  72. data/lib/sequel/plugins/instance_filters.rb +4 -1
  73. data/lib/sequel/plugins/inverted_subsets.rb +1 -0
  74. data/lib/sequel/plugins/lazy_attributes.rb +1 -1
  75. data/lib/sequel/plugins/nested_attributes.rb +10 -5
  76. data/lib/sequel/plugins/optimistic_locking.rb +2 -0
  77. data/lib/sequel/plugins/paged_operations.rb +5 -2
  78. data/lib/sequel/plugins/pg_auto_constraint_validations.rb +6 -1
  79. data/lib/sequel/plugins/pg_auto_validate_enums.rb +88 -0
  80. data/lib/sequel/plugins/pg_eager_any_typed_array.rb +95 -0
  81. data/lib/sequel/plugins/rcte_tree.rb +1 -1
  82. data/lib/sequel/plugins/serialization.rb +11 -5
  83. data/lib/sequel/plugins/sql_comments.rb +7 -2
  84. data/lib/sequel/plugins/static_cache_cache.rb +50 -13
  85. data/lib/sequel/plugins/subset_conditions.rb +85 -5
  86. data/lib/sequel/plugins/subset_static_cache.rb +263 -0
  87. data/lib/sequel/plugins/tactical_eager_loading.rb +6 -2
  88. data/lib/sequel/plugins/validate_associated.rb +1 -1
  89. data/lib/sequel/sql.rb +16 -6
  90. data/lib/sequel/version.rb +1 -1
  91. metadata +12 -234
  92. data/CHANGELOG +0 -1355
  93. data/README.rdoc +0 -936
  94. data/doc/advanced_associations.rdoc +0 -884
  95. data/doc/association_basics.rdoc +0 -1859
  96. data/doc/bin_sequel.rdoc +0 -146
  97. data/doc/cheat_sheet.rdoc +0 -255
  98. data/doc/code_order.rdoc +0 -102
  99. data/doc/core_extensions.rdoc +0 -405
  100. data/doc/dataset_basics.rdoc +0 -96
  101. data/doc/dataset_filtering.rdoc +0 -222
  102. data/doc/extensions.rdoc +0 -77
  103. data/doc/fork_safety.rdoc +0 -84
  104. data/doc/mass_assignment.rdoc +0 -98
  105. data/doc/migration.rdoc +0 -660
  106. data/doc/model_dataset_method_design.rdoc +0 -129
  107. data/doc/model_hooks.rdoc +0 -254
  108. data/doc/model_plugins.rdoc +0 -270
  109. data/doc/mssql_stored_procedures.rdoc +0 -43
  110. data/doc/object_model.rdoc +0 -563
  111. data/doc/opening_databases.rdoc +0 -436
  112. data/doc/postgresql.rdoc +0 -611
  113. data/doc/prepared_statements.rdoc +0 -144
  114. data/doc/querying.rdoc +0 -1070
  115. data/doc/reflection.rdoc +0 -120
  116. data/doc/release_notes/5.0.0.txt +0 -159
  117. data/doc/release_notes/5.1.0.txt +0 -31
  118. data/doc/release_notes/5.10.0.txt +0 -84
  119. data/doc/release_notes/5.11.0.txt +0 -83
  120. data/doc/release_notes/5.12.0.txt +0 -141
  121. data/doc/release_notes/5.13.0.txt +0 -27
  122. data/doc/release_notes/5.14.0.txt +0 -63
  123. data/doc/release_notes/5.15.0.txt +0 -39
  124. data/doc/release_notes/5.16.0.txt +0 -110
  125. data/doc/release_notes/5.17.0.txt +0 -31
  126. data/doc/release_notes/5.18.0.txt +0 -69
  127. data/doc/release_notes/5.19.0.txt +0 -28
  128. data/doc/release_notes/5.2.0.txt +0 -33
  129. data/doc/release_notes/5.20.0.txt +0 -89
  130. data/doc/release_notes/5.21.0.txt +0 -87
  131. data/doc/release_notes/5.22.0.txt +0 -48
  132. data/doc/release_notes/5.23.0.txt +0 -56
  133. data/doc/release_notes/5.24.0.txt +0 -56
  134. data/doc/release_notes/5.25.0.txt +0 -32
  135. data/doc/release_notes/5.26.0.txt +0 -35
  136. data/doc/release_notes/5.27.0.txt +0 -21
  137. data/doc/release_notes/5.28.0.txt +0 -16
  138. data/doc/release_notes/5.29.0.txt +0 -22
  139. data/doc/release_notes/5.3.0.txt +0 -121
  140. data/doc/release_notes/5.30.0.txt +0 -20
  141. data/doc/release_notes/5.31.0.txt +0 -148
  142. data/doc/release_notes/5.32.0.txt +0 -46
  143. data/doc/release_notes/5.33.0.txt +0 -24
  144. data/doc/release_notes/5.34.0.txt +0 -40
  145. data/doc/release_notes/5.35.0.txt +0 -56
  146. data/doc/release_notes/5.36.0.txt +0 -60
  147. data/doc/release_notes/5.37.0.txt +0 -30
  148. data/doc/release_notes/5.38.0.txt +0 -28
  149. data/doc/release_notes/5.39.0.txt +0 -19
  150. data/doc/release_notes/5.4.0.txt +0 -80
  151. data/doc/release_notes/5.40.0.txt +0 -40
  152. data/doc/release_notes/5.41.0.txt +0 -25
  153. data/doc/release_notes/5.42.0.txt +0 -136
  154. data/doc/release_notes/5.43.0.txt +0 -98
  155. data/doc/release_notes/5.44.0.txt +0 -32
  156. data/doc/release_notes/5.45.0.txt +0 -34
  157. data/doc/release_notes/5.46.0.txt +0 -87
  158. data/doc/release_notes/5.47.0.txt +0 -59
  159. data/doc/release_notes/5.48.0.txt +0 -14
  160. data/doc/release_notes/5.49.0.txt +0 -59
  161. data/doc/release_notes/5.5.0.txt +0 -61
  162. data/doc/release_notes/5.50.0.txt +0 -78
  163. data/doc/release_notes/5.51.0.txt +0 -47
  164. data/doc/release_notes/5.52.0.txt +0 -87
  165. data/doc/release_notes/5.53.0.txt +0 -23
  166. data/doc/release_notes/5.54.0.txt +0 -27
  167. data/doc/release_notes/5.55.0.txt +0 -21
  168. data/doc/release_notes/5.56.0.txt +0 -51
  169. data/doc/release_notes/5.57.0.txt +0 -23
  170. data/doc/release_notes/5.58.0.txt +0 -31
  171. data/doc/release_notes/5.59.0.txt +0 -73
  172. data/doc/release_notes/5.6.0.txt +0 -31
  173. data/doc/release_notes/5.60.0.txt +0 -22
  174. data/doc/release_notes/5.61.0.txt +0 -43
  175. data/doc/release_notes/5.62.0.txt +0 -132
  176. data/doc/release_notes/5.63.0.txt +0 -33
  177. data/doc/release_notes/5.64.0.txt +0 -50
  178. data/doc/release_notes/5.65.0.txt +0 -21
  179. data/doc/release_notes/5.66.0.txt +0 -24
  180. data/doc/release_notes/5.67.0.txt +0 -32
  181. data/doc/release_notes/5.68.0.txt +0 -61
  182. data/doc/release_notes/5.69.0.txt +0 -26
  183. data/doc/release_notes/5.7.0.txt +0 -108
  184. data/doc/release_notes/5.70.0.txt +0 -35
  185. data/doc/release_notes/5.71.0.txt +0 -21
  186. data/doc/release_notes/5.72.0.txt +0 -33
  187. data/doc/release_notes/5.73.0.txt +0 -66
  188. data/doc/release_notes/5.74.0.txt +0 -45
  189. data/doc/release_notes/5.75.0.txt +0 -35
  190. data/doc/release_notes/5.76.0.txt +0 -86
  191. data/doc/release_notes/5.77.0.txt +0 -63
  192. data/doc/release_notes/5.78.0.txt +0 -67
  193. data/doc/release_notes/5.79.0.txt +0 -28
  194. data/doc/release_notes/5.8.0.txt +0 -170
  195. data/doc/release_notes/5.80.0.txt +0 -40
  196. data/doc/release_notes/5.9.0.txt +0 -99
  197. data/doc/schema_modification.rdoc +0 -679
  198. data/doc/security.rdoc +0 -443
  199. data/doc/sharding.rdoc +0 -286
  200. data/doc/sql.rdoc +0 -648
  201. data/doc/testing.rdoc +0 -190
  202. data/doc/thread_safety.rdoc +0 -15
  203. data/doc/transactions.rdoc +0 -250
  204. data/doc/validations.rdoc +0 -558
  205. data/doc/virtual_rows.rdoc +0 -265
@@ -1,436 +0,0 @@
1
- = Connecting to a database
2
-
3
- All Sequel activity begins with connecting to a database, which creates a
4
- Sequel::Database object. The Database object is used to create datasets and execute
5
- queries. Sequel provides a powerful and flexible mechanism for connecting to
6
- databases. There are two main ways to establish database connections:
7
-
8
- 1. Using the Sequel.connect method
9
- 2. Using the specialized adapter method (Sequel.sqlite, Sequel.postgres, etc.)
10
-
11
- The connection options needed depend on the adapter being used, though most adapters
12
- share the same basic connection options.
13
-
14
- If you are only connecting to a single database, it is recommended that you store the
15
- database object in a constant named DB. This is not required, but it is the
16
- convention that most Sequel code uses.
17
-
18
- == Using the Sequel.connect method
19
-
20
- The connect method usually takes a well-formed URI, which is parsed into connection options needed to open
21
- the database connection. The scheme/protocol part of the URI is used to determine the adapter to use:
22
-
23
- DB = Sequel.connect('postgres://user:password@localhost/blog') # Uses the postgres adapter
24
-
25
- You can use URI query parameters to specify options:
26
-
27
- DB = Sequel.connect('postgres://localhost/blog?user=user&password=password')
28
-
29
- You can also pass an additional option hash with the connection string:
30
-
31
- DB = Sequel.connect('postgres://localhost/blog', user: 'user', password: 'password')
32
-
33
- You can also just use an options hash without a connection string. If you do this, you must
34
- provide the adapter to use:
35
-
36
- DB = Sequel.connect(adapter: 'postgres', host: 'localhost', database: 'blog', user: 'user', password: 'password')
37
-
38
- All of the above statements are equivalent.
39
-
40
- == Using the specialized adapter method
41
-
42
- The specialized adapter method is similar to Sequel.connect with an options hash, except that it
43
- automatically populates the :adapter option and assumes the first argument is the :database option,
44
- unless the first argument is a hash. So the following statements are equivalent to the previous statements.
45
-
46
- DB = Sequel.postgres('blog', host: 'localhost', user: 'user', password: 'password')
47
- DB = Sequel.postgres(host: 'localhost', user: 'user', password: 'password', database: 'blog')
48
-
49
- Note that using an adapter method forces the use of the specified adapter, not a database type, even
50
- though some adapters have the same name as the database type. So if you
51
- want to connect to SQLite, for example, you can do so using the sqlite, amalgalite, and jdbc adapters.
52
- If you want to connect to SQLite on JRuby using the jdbc adapter, you should not use <tt>Sequel.sqlite</tt>
53
- for example, as that uses the C-based sqlite3 gem. Instead, the <tt>Sequel.jdbc</tt> would be appropriate (though
54
- as mentioned below, using <tt>Sequel.connect</tt> is recommended instead of <tt>Sequel.jdbc</tt>).
55
-
56
- == Passing a block to either method
57
-
58
- Both the Sequel.connect method and the specialized adapter methods take a block. If you
59
- provide a block to the method, Sequel will create a Database object and pass it as an argument
60
- to the block. When the block returns, Sequel will disconnect the database connection.
61
- For example:
62
-
63
- Sequel.connect('sqlite://blog.db'){|db| puts db[:users].count}
64
-
65
- Note that if you do not pass a block to Sequel.connect, Sequel will automatically retain a
66
- reference to the object in the <tt>Sequel::DATABASES</tt> array. So calling +Sequel.connect+
67
- multiple times (say once per request), can result in a memory leak. For any application where
68
- database access is needed for a long period of time, it's best to store the result of
69
- Sequel.connection in a constant, as recommended above.
70
-
71
- == Using the Sequel.connect method
72
- == General connection options
73
-
74
- These options are shared by all adapters unless otherwise noted.
75
-
76
- :adapter :: The adapter to use
77
- :database :: The name of the database to which to connect
78
- :extensions :: Extensions to load into this Database instance. Can be a symbol, array of symbols,
79
- or string with extensions separated by columns. These extensions are loaded after
80
- connections are made by the :preconnect option.
81
- :cache_schema :: Whether schema should be cached for this database (true by default)
82
- :default_string_column_size :: The default size for string columns (255 by default)
83
- :host :: The hostname of the database server to which to connect
84
- :keep_reference :: Whether to keep a reference to the database in Sequel::DATABASES (true by default)
85
- :logger :: A specific SQL logger to log to
86
- :loggers :: An array of SQL loggers to log to
87
- :log_connection_info :: Whether to include connection information in log messages (false by default)
88
- :log_warn_duration :: The amount of seconds after which the queries are logged at :warn level
89
- :password :: The password for the user account
90
- :preconnect :: Whether to automatically make the maximum number of connections when setting up the pool.
91
- Can be set to "concurrently" to connect in parallel.
92
- :preconnect_extensions :: Similar to the :extensions option, but loads the extensions before the
93
- connections are made by the :preconnect option.
94
- :quote_identifiers :: Whether to quote identifiers.
95
- :servers :: A hash with symbol keys and hash or proc values, used with primary/replica and sharded database configurations
96
- :sql_log_level :: The level at which to issue queries to the loggers (:info by default)
97
- :test :: Whether to test that a valid database connection can be made (true by default)
98
- :user :: The user account name to use logging in
99
-
100
- The following options can be specified and are passed to the database's internal connection pool.
101
-
102
- :after_connect :: A callable object called after each new connection is made, with the
103
- connection object (and server argument if the callable accepts 2 arguments),
104
- useful for customizations that you want to apply to all connections (nil by default).
105
- :connect_sqls :: An array of sql strings to execute on each new connection, after :after_connect runs.
106
- :max_connections :: The maximum size of the connection pool (4 connections by default on most databases)
107
- :pool_timeout :: The number of seconds to wait if a connection cannot be acquired before raising an error (5 seconds by default)
108
- :single_threaded :: Whether to use a single-threaded (non-thread safe) connection pool
109
-
110
- == Adapter specific connection options
111
-
112
- The following sections explain the options and behavior specific to each adapter.
113
- If the library the adapter requires is different from the name of the adapter
114
- scheme, it is listed specifically, otherwise you can assume that is requires the
115
- library with the same name.
116
-
117
- === ado
118
-
119
- Requires: win32ole
120
-
121
- The ADO adapter provides connectivity to ADO databases in Windows. It relies
122
- on WIN32OLE library, so it isn't usable on other operating systems (except
123
- possibly through WINE, but that's unlikely).
124
-
125
- The following options are supported:
126
-
127
- :command_timeout :: Sets the time in seconds to wait while attempting
128
- to execute a command before cancelling the attempt and generating
129
- an error. Specifically, it sets the ADO CommandTimeout property.
130
- :driver :: The driver to use in the ADO connection string. If not provided, a default
131
- of "SQL Server" is used.
132
- :conn_string :: The full ADO connection string. If this is provided,
133
- the usual options are ignored.
134
- :provider :: Sets the Provider of this ADO connection (for example, "SQLOLEDB").
135
- If you don't specify a provider, the default one used by WIN32OLE
136
- has major problems, such as creating a new native database connection
137
- for every query, which breaks things such as transactions and temporary tables.
138
-
139
- Pay special attention to the :provider option, as without specifying a provider,
140
- many things will be broken. The SQLNCLI10 and SQLNCLI11 providers work well if you
141
- are connecting to Microsoft SQL Server, but it is not the default as it depends on
142
- those providers being installed.
143
-
144
- Example connections:
145
-
146
- # SQL Server
147
- Sequel.connect('ado:///sequel_test?host=server%5cdb_instance')
148
- Sequel.connect('ado://user:password@server/database?host=server%5cdb_instance&provider=SQLNCLI10')
149
- # Access 2007
150
- Sequel.ado(conn_string: 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=drive:\\path\\filename.accdb')
151
- # Access 2000
152
- Sequel.ado(conn_string: 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=drive:\\path\\filename.mdb')
153
- # Excel 2000 (for table names, use a dollar after the sheet name, e.g. Sheet1$)
154
- Sequel.ado(conn_string: 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=drive:\\path\\filename.xls;Extended Properties=Excel 8.0;')
155
-
156
- === amalgalite
157
-
158
- Amalgalite is an ruby extension that provides self contained access to SQLite,
159
- so you don't need to install SQLite separately. As amalgalite is a file backed
160
- database, the :host, :user, and :password options are not used.
161
-
162
- :database :: The name of the database file
163
- :timeout :: The busy timeout period given in milliseconds
164
-
165
- Without a database argument, assumes a memory database, so you can do:
166
-
167
- Sequel.amalgalite
168
-
169
- Handles paths in the connection string similar to the SQLite adapter, so see
170
- the sqlite section below for details.
171
-
172
- === ibmdb
173
-
174
- requires 'ibm_db'
175
-
176
- This connects to DB2 using IBM_DB. This is the recommended adapter if you are
177
- using a C-based ruby to connect to DB2.
178
-
179
- === jdbc
180
-
181
- Requires: java
182
-
183
- Houses Sequel's JDBC support when running on JRuby.
184
- Support for individual database types is done using subadapters.
185
- There are currently subadapters for DB2, Derby, H2, HSQLDB, JTDS,
186
- MySQL, Oracle, PostgreSQL, SQLAnywhere, SQLite, and SQL Server.
187
- For Derby, H2, HSQLDB, JTDS, MySQL, Postgres, SQLite3
188
- the adapters can use the `jdbc-*` gem, for the others you need to have the `.jar` in your CLASSPATH
189
- or load the Java class manually before calling Sequel.connect.
190
-
191
- Note that when using a JDBC adapter, the best way to use Sequel
192
- is via Sequel.connect using a connection string, NOT Sequel.jdbc. Use the JDBC connection
193
- string when connecting, which will be in a different format than
194
- the native connection string. The connection string should start
195
- with 'jdbc:'. For PostgreSQL, use 'jdbc:postgresql:', and for
196
- SQLite you do not need 2 preceding slashes for the database name
197
- (use no preceding slashes for a relative path, and one preceding
198
- slash for an absolute path).
199
-
200
- Sequel does no preprocessing of JDBC connection strings, it passes them directly to JDBC.
201
- So if you have problems getting a connection string to work, look up the
202
- documentation for the JDBC driver.
203
-
204
- The jdbc adapter does not handle common options such as +:host+,
205
- +:user+, and +:port+. If you must use a hash of options when connecting,
206
- provide the full JDBC connection string as the :uri option.
207
-
208
- Example connection strings:
209
-
210
- jdbc:sqlite::memory:
211
- jdbc:postgresql://localhost/database?user=username
212
- jdbc:mysql://localhost/test?user=root&password=root&serverTimezone=UTC
213
- jdbc:h2:mem:
214
- jdbc:hsqldb:mem:mymemdb
215
- jdbc:derby:memory:myDb;create=true
216
- jdbc:sqlserver://localhost;database=sequel_test;integratedSecurity=true
217
- jdbc:jtds:sqlserver://localhost/sequel_test;user=sequel_test;password=sequel_test
218
- jdbc:oracle:thin:user/password@localhost:1521:database
219
- jdbc:db2://localhost:3700/database:user=user;password=password;
220
- jdbc:sqlanywhere://localhost?DBN=Test;UID=user;PWD=password
221
-
222
- You can also use JNDI connection strings:
223
-
224
- jdbc:jndi:java:comp/env/jndi_resource_name
225
-
226
- The following additional options are supported:
227
-
228
- :convert_types :: If set to false, does not attempt to convert some Java types to ruby types.
229
- Setting to false roughly doubles performance when selecting large numbers of rows.
230
- Note that you can't provide this option inside the connection string (as that is passed
231
- directly to JDBC), you have to pass it as a separate option.
232
- :driver :: Specify the Java driver class to use to connect to the database. This only has
233
- an effect if the database type is not recognized from the connection string,
234
- and only helps cases where <tt>java.sql.DriverManager.getConnection</tt> does not
235
- return a connection.
236
- :login_timeout :: Set the login timeout on the JDBC connection (in seconds).
237
- :jdbc_properties :: A hash for properties to set, skips the normal connection process of using
238
- java.sql.drivermanager.getconnection and tries the backup process of using
239
- driver.new.connect for the appropriate driver.
240
-
241
- There are a few issues with specific jdbc driver gems:
242
-
243
- jdbc-h2 :: jdbc-h2 versions greater than 1.3.175 have issues with ORDER BY not working correctly in some cases.
244
- jdbc-mysql :: Depending on the configuration of the MySQL server, jdbc-mysql versions greater 8 may complain
245
- about the server time zone being unrecognized. You can either use an older jdbc-mysql version,
246
- or you can specify the +serverTimezone+ option in the connection string, as shown in the example
247
- jdbc:mysql connection string above.
248
-
249
- === mysql
250
-
251
- Requires: mysql
252
-
253
- This should work with the mysql gem (C extension) and the ruby-mysql gem (pure ruby).
254
-
255
- The following additional options are supported:
256
-
257
- :auto_is_null :: If set to true, makes "WHERE primary_key IS NULL" select the last inserted id.
258
- :charset :: Same as :encoding, :encoding takes precedence.
259
- :compress :: Whether to compress data sent/received via the socket connection.
260
- :config_default_group :: The default group to read from the in the MySQL config file, defaults to "client")
261
- :config_local_infile :: If provided, sets the Mysql::OPT_LOCAL_INFILE option on the connection with the given value.
262
- :disable_split_materialized :: Set split_materialized=off in the optimizer settings. Necessary to pass the associations
263
- integration tests in MariaDB 10.5+, due to a unfixed bug in the optimizer.
264
- :encoding :: Specify the encoding/character set to use for the connection.
265
- :fractional_seconds :: On MySQL 5.6.5+, this option is recognized and will include fractional seconds in
266
- time/timestamp values, as well as have the schema method create columns that can contain
267
- fractional seconds by deafult. This option is also supported on other adapters that connect
268
- to MySQL.
269
- :socket :: Can be used to specify a Unix socket file to connect to instead of a TCP host and port.
270
- :sql_mode :: Set the sql_mode(s) for a given connection. Can be single symbol or string,
271
- or an array of symbols or strings (e.g. <tt>sql_mode: [:no_zero_date, :pipes_as_concat]</tt>).
272
- :timeout :: Sets the wait_timeout for the connection, defaults to 1 month.
273
- :read_timeout :: Set the timeout in seconds for reading back results to a query.
274
- :connect_timeout :: Set the timeout in seconds before a connection attempt is abandoned
275
- (may not be supported when using MariaDB 10.2+ client libraries).
276
-
277
- The :sslkey, :sslcert, :sslca, :sslcapath, and :sslca options (in that order) are passed to Mysql#ssl_set method
278
- if either the :sslca or :sslkey option is given.
279
-
280
- === mysql2
281
-
282
- This is a MySQL adapter that does typecasting in C, so it is often faster than the
283
- mysql adapter. The options given are passed to Mysql2::Client.new, see the mysql2 documentation
284
- for details on what options are supported. The :timeout, :auto_is_null, :sql_mode, and :disable_split_materialized
285
- options supported by the mysql adapter are also supported for mysql2 adapter (and any other adapters connecting to
286
- mysql, such as the jdbc/mysql adapter).
287
-
288
- === odbc
289
-
290
- The ODBC adapter allows you to connect to any database with the appropriate ODBC drivers installed.
291
- The :database option given ODBC database should be the DSN (Descriptive Service Name) from the ODBC configuration.
292
-
293
- Sequel.odbc('mydb', user: "user", password: "password")
294
-
295
- The :host and :port options are not respected. The following additional options are supported:
296
-
297
- :db_type :: Can be specified as 'mssql', 'progress', or 'db2' to use SQL syntax specific to those databases.
298
- :drvconnect :: Can be given an ODBC connection string, and will use ODBC::Database#drvconnect to
299
- do the connection. Typical usage would be: <tt>Sequel.odbc(drvconnect: 'driver={...};...')</tt>
300
-
301
- === oracle
302
-
303
- Requires: oci8
304
-
305
- The following additional options are supported:
306
-
307
- :autosequence :: Set to true to use Sequel's conventions to guess the sequence to use for datasets. False
308
- by default.
309
- :prefetch_rows :: The number of rows to prefetch. Defaults to 100, a larger number can be specified
310
- and may improve performance when retrieving a large number of rows.
311
- :privilege :: The Oracle privilege level.
312
-
313
- === postgres
314
-
315
- Requires: pg (or sequel/postgres-pr or postgres-pr/postgres-compat if pg is not available)
316
-
317
- The Sequel postgres adapter works with the pg, sequel-postgres-pr, jeremyevans-postgres-pr, and postgres-pr ruby libraries.
318
- The pg library is the best supported, as it supports real bound variables and prepared statements.
319
- If the pg library is being used, Sequel will also attempt to load the sequel_pg library, which is
320
- a C extension that optimizes performance when Sequel is used with pg. All users of Sequel who
321
- use pg are encouraged to install sequel_pg. For users who want to use one of the postgres-pr
322
- libraries to avoid issues with C extensions, it is recommended to use sequel-postgres-pr.
323
-
324
- The following additional options are supported:
325
-
326
- :charset :: Same as :encoding, :encoding takes precedence
327
- :convert_infinite_timestamps :: Whether infinite timestamps/dates should be converted on retrieval. By default, no
328
- conversion is done, so an error is raised if you attempt to retrieve an infinite
329
- timestamp/date. You can set this to :nil to convert to nil, :string to leave
330
- as a string, or :float to convert to an infinite float.
331
- :conn_str :: Use connection string (in form of `host=x port=y ...`). Ignores all other options, only supported with pg
332
- library. See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING and
333
- https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS for format and list of supported
334
- options.
335
- :connect_timeout :: Set the number of seconds to wait for a connection (default 20, only respected
336
- if using the pg library).
337
- :driver_options :: A hash of options to pass to the underlying driver (only respected if using the pg library)
338
- :encoding :: Set the client_encoding to the given string
339
- :notice_receiver :: A proc that be called with the PGresult objects that have notice or warning messages.
340
- The default notice receiver just prints the messages to stderr, but this can be used
341
- to handle notice/warning messages differently. Only respected if using the pg library).
342
- :sslmode :: Set to 'disable', 'allow', 'prefer', 'require', 'verify-ca', or 'verify-full' to choose how to treat SSL (only
343
- respected if using the pg library)
344
- :sslrootcert :: Specify the path to the root SSL certificate to use.
345
- :search_path :: Set to the schema search_path. This can either be a single string containing the schemas
346
- separated by commas (for use via a URL: <tt>postgres:///?search_path=schema1,schema2</tt>), or it
347
- can be an array of strings (for use via an option:
348
- <tt>Sequel.postgres(search_path: ['schema1', 'schema2'])</tt>).
349
- :unlogged_tables_default :: Set to true to use UNLOGGED by default for created tables, for potentially better performance
350
- when data integrity is not important.
351
- :use_iso_date_format :: This can be set to false to not force the ISO date format. Sequel forces
352
- it by default to allow for an optimization.
353
-
354
- === sqlanywhere
355
-
356
- The sqlanywhere driver works off connection strings, so a connection string
357
- is built based on the url/options hash provided. The following additional
358
- options are respected:
359
-
360
- :commlinks :: specify the CommLinks connection string option
361
- :conn_string :: specify the connection string to use, ignoring all other options
362
- :connection_name :: specify the ConnectionName connection string option
363
- :encoding :: specify the CharSet connection string option
364
-
365
- === sqlite
366
-
367
- Requires: sqlite3
368
-
369
- As SQLite is a file-based database, the :host and :port options are ignored, and
370
- the :database option should be a path to the file.
371
-
372
- Examples:
373
-
374
- # In Memory databases:
375
- Sequel.sqlite
376
- Sequel.connect('sqlite:/')
377
- Sequel.sqlite(':memory:')
378
-
379
- # Relative Path
380
- Sequel.sqlite('blog.db')
381
- Sequel.sqlite('./blog.db')
382
- Sequel.connect('sqlite://blog.db')
383
-
384
- # Absolute Path
385
- Sequel.sqlite('/var/sqlite/blog.db')
386
- Sequel.connect('sqlite:///var/sqlite/blog.db')
387
-
388
- The following additional options are supported:
389
-
390
- :readonly :: open database in read-only mode
391
- :timeout :: the busy timeout to use in milliseconds (default: 5000).
392
- :setup_regexp_function :: Whether to setup a REGEXP function in the underlying SQLite3::Database object. Doing so
393
- allows you to use regexp support in dataset expressions. If +:cached+ or <tt>"cached"</tt>+, caches each
394
- unique regex (more efficient but risk of memory leak). If a Proc is provided, it will be called with
395
- a string for the regexp and a string for the value to compare, and should return whether the regexp
396
- string matches the string value to compare. The default Proc used does <tt>Regexp.new(regexp_str).match(str)</tt>.
397
-
398
- Note that SQLite memory databases are restricted to a single connection by
399
- default. This is because SQLite does not allow multiple connections to
400
- a single memory database. For this reason, Sequel sets the maximum number
401
- of connections in the connection pool to 1 by default when an SQLite memory
402
- database is used. Attempts to force the use of more than 1 connection
403
- can result in weird behavior, since the connections will be to separate
404
- memory databases.
405
-
406
- === tinytds
407
-
408
- Requires: tiny_tds
409
-
410
- The connection options are passed directly
411
- to tiny_tds, except that the tiny_tds :username option is set to
412
- the Sequel :user option. If you want to use an entry in the freetds.conf file, you
413
- should specify the :dataserver option with that name as the value. Some other
414
- options that you may want to set are :login_timeout, :timeout, :tds_version, :azure,
415
- :appname, and :encoding, see the tiny_tds README for details.
416
-
417
- Other Sequel specific options:
418
-
419
- :ansi :: Set to true to enable the ANSI compatibility settings when connecting
420
- (ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ANSI_NULL_DFLT_ON, QUOTED_IDENTIFIER,
421
- CONCAT_NULL_YIELDS_NULL).
422
- :server_version :: Override the server version to use (9000000 = SQL Server 2005).
423
- This also works on any other adapter that connects to Microsoft
424
- SQL Server.
425
- :textsize :: Override the default TEXTSIZE setting for this connection. The FreeTDS
426
- default is small (around 64000 bytes), but can be set up to around 2GB.
427
- This should be specified as an integer. If you plan on setting large
428
- text or blob values via tinytds, you should use this option or modify
429
- your freetds.conf file.
430
-
431
- === trilogy
432
-
433
- This is a MySQL adapter that does typecasting in C, and does not require any mysql client libraries installed.
434
- The options given are passed to Trilogy.new, see the trilogy documentation for details on what options are
435
- supported. The :timeout, :auto_is_null, :sql_mode, and :disable_split_materialized
436
- options supported by the mysql adapter are also supported for trilogy adapter.