Commit graph

28 commits

Author SHA1 Message Date
Jeremy Woertink
b1299fcada
Raise a specific class error instead of string literal (#156)
* Raise a specific class error instead of string literal when the type returned doesn't match the type expected. Allows for drivers to catch the specific error.

* Add ResultSet#next_column_index

* Add shared specs for next_column_index

* Add properties to ColumnTypeMismatchError

* Add shared specs for ColumnTypeMismatchError

* Fix specs

Co-authored-by: Brian J. Cardiff <bcardiff@gmail.com>
2021-10-12 20:49:26 -03:00
Brian J. Cardiff
7253551849
Add logging for executing queries (#134)
* Add logging for executing queries

Arguments are translated to Log::Metadata::Value via DB::Statement#arg_to_log method.

DB::Statement#before_query_or_exec & after_query_or_exec protected methods can be used to hook and run around the statement execution

* Move the metadata converter to a module

* Replace before/after with def_around_query_or_exec macro

* Update src/db/enumerable_concat.cr

Co-authored-by: Ary Borenszweig <asterite@gmail.com>

Co-authored-by: Ary Borenszweig <asterite@gmail.com>
2020-09-25 14:49:50 -03:00
Johannes Müller
b3898ae2a2 Statement#exec and #query require named argument for array values (#110)
This change allows to use an array as single argument for #exec and
 #query and #scalar methods. Before it was shadowed by the *args splat overload.
2019-09-20 17:23:09 -03:00
Brian J. Cardiff
adc755e5e4
Add type argument to QueryMethods module (#108) 2019-08-02 11:54:52 -03:00
Brian J. Cardiff
ac083f430a Updates for crystal 0.24.0 2017-12-29 20:13:34 -03:00
Brian J. Cardiff
9b03aa6535 Release connection when unprepared statements can't be built
Add specs
Fix typo in docs
2017-09-07 19:21:36 -03:00
Brian J. Cardiff
385cf70a8a Introduce DB::ConnectionContext (#44)
* make Database a ConnectionContext.
* introduce SingleConnectionContext for independant connections.
* add `DB#connect` to create non pooled connections.
2017-03-20 15:08:30 -03:00
Brian J. Cardiff
c491bd8962 add nested transaction with savepoints 2016-12-13 16:47:23 -03:00
Brian J. Cardiff
751f8b26ac Transactions
* dsl, state checks
* define transaction sql commands in connection
2016-12-13 16:47:23 -03:00
Brian J. Cardiff
4721ecbf6b make Connection#prepared_statements? readonly 2016-12-07 01:50:06 -03:00
Brian J. Cardiff
fe0ed55ef9 introduce unprepared statements
* rename QueryMethods#prepare to QueryMethods#build
* rename Connection#build_statement to Connection#build_prepared_statement
* add Connection#build_unprepared_statement
* add Connection #prepared and #unprepared dsl methods
2016-12-07 01:50:06 -03:00
Brian J. Cardiff
cd10dabba2 default max_pool_size to 0 = unlimited 2016-11-13 18:21:05 -03:00
Brian J. Cardiff
47e7d826e8 Add connection retry logic to connection pool 2016-08-31 17:32:01 -03:00
Brian J. Cardiff
6a0a450622 make statement_specs run over a single connection 2016-08-29 16:50:37 -03:00
Brian J. Cardiff
3c91978d36 Merged branch master into feature/pool 2016-08-29 12:57:42 -03:00
Brian J. Cardiff
325fa9d4ae ensure the connection is released after exec
avoid releasing connection twice on exec.
avoid releasing connection when QueryMethod#query is blockless called.
2016-08-29 01:23:20 -03:00
Brian J. Cardiff
a2c22c16cf allow DB to use a connection pool.
allow Driver to parse connection pool options for extensibility.
fix waiting_resource counter after a timeout was generated.
2016-07-07 15:50:09 -03:00
Santiago Palladino
552b6e12b4 Rebase to latest DB version and upgrade to Crystal 0.18 2016-07-04 12:13:39 -03:00
Santiago Palladino
6b065bd6b6 Handle different number of columns in dummy driver
Number of cols is inferred from the number of fields in the first row.
2016-07-04 11:15:04 -03:00
Ary Borenszweig
9c88f718e8 Require ResultSet to just implement read, optionally implementing read(T.class). Fixes #5 2016-06-30 09:46:25 -03:00
Brian J. Cardiff
8025ecaa13 update Slice(UInt8) to Bytes 2016-06-22 14:10:09 -03:00
Brian J. Cardiff
11e24e1c65 #5 Make sure queries (insert and query) work with any type 2016-06-22 00:44:16 -03:00
Brian J. Cardiff
c5d7778a0d update DB::ExecResult#rows_affected to Int64 2016-06-21 18:31:13 -03:00
Brian J. Cardiff
76e3a35d59 allow exec to receive any object arguments 2016-06-21 10:55:44 -03:00
Brian J. Cardiff
3464a1d1cc allow query to receive any object arguments 2016-06-21 10:55:41 -03:00
Brian J. Cardiff
d69555b372 make Nil a proper column type 2016-06-21 10:53:34 -03:00
Ary Borenszweig
f834b0f8a6 Updated to Crystal 0.17.4 2016-06-16 12:16:39 -03:00
Brian J. Cardiff
44559f6f95 move spec and src files to a shardy way 2016-02-25 22:37:10 -03:00
Renamed from spec/std/db/dummy_driver.cr (Browse further)