Commit graph

244 commits

Author SHA1 Message Date
Brian J. Cardiff
cd107ca635 Drop checkout_some, simpler pool_prepared statement 2023-11-30 11:26:13 -03:00
Brian J. Cardiff
684b8ac032 Add pool_concurrency_test manual spec
Add MT connection count without Mutex
2023-11-30 11:26:13 -03:00
Lachlan Dowding
06df272740
Add exception cause support to PoolResourceLost and ConnectionLost (#199)
constructors
2023-11-30 09:36:00 -03:00
Brian J. Cardiff
d3dd978e24
Allow statements to auto close when consumed if no cache (#198) 2023-11-29 18:39:44 -03:00
Johannes Müller
76d8bb6a6e
Deprecate DB.mapping (#196) 2023-11-13 17:44:39 +01:00
Johannes Müller
340b6e4b9a
Add reference to DB::Serializable in docs (#197) 2023-11-09 08:22:51 -03:00
Brian J. Cardiff
285e865e3a
Allow prepared_statements_cache=false option to disable prepared statements cache (#194)
* Add prepared_statements_cache in connection to opt-out

* Honor prepared_statements_cache option in database also
2023-11-03 23:04:14 -03:00
wonderix
9b52a65752 Add link to crystal-tds 2023-11-02 18:45:45 -03:00
Lachlan Dowding
a527cfdc4e
Fix DB::DriverSpecs#with_db connection_string query param support (#192) 2023-10-31 10:10:25 -03:00
Brian J. Cardiff
38faf7eeba
Update docs regarding ConnectionBuilder (#188) 2023-08-14 21:11:35 -03:00
Brian J. Cardiff
9471b33ffe
Fix max_idle_pool_size race condition (#186)
* Add Fiber.yield to dummy driver to mimic real drivers IO

* Add manual load test file

* Fix race condition

* Drop unused code

* Less state, less bugs

* Update spec/manual/load_test.cr

Co-authored-by: Beta Ziliani <beta@manas.tech>

---------

Co-authored-by: Beta Ziliani <beta@manas.tech>
2023-07-31 11:04:18 -03:00
Jamie Gaskins
ce95cd2257
Decrement the inflight counter on ConnectionRefused (#184) 2023-07-10 10:55:35 -03:00
Brian J. Cardiff
851091e81c
Release 0.12.0 (#183)
* Release 0.12.0

* Update CHANGELOG.md

Co-authored-by: Johannes Müller <straightshoota@gmail.com>

---------

Co-authored-by: Johannes Müller <straightshoota@gmail.com>
2023-06-23 13:48:41 -03:00
Brian J. Cardiff
f13846b133
Refactor connection factory (#181)
* Start moving out URI from ConnectionContext

Create connections with an initial context. Database will set itself as context after connection has been created

* Migrate to simpler/decoupled factory in driver

This allows more freedom on how the connection is created. It will no longer need to have an explicit reference to the connection URI

* Introduce DB::Connection::Options

Move prepared_statements out from ConnectionContext

* Delegate options parsing to driver

DRY parsing connection options for database

* Introduce DB::Pool::Options

* Rename Driver#connection_pool_options to pool_options

* Drop driver getter from database

* Drop uri getter from database

* Add public Database#initialize method

* Drop :nodoc: Database#initialize

* Pass spec helper explicitly (to access methods within each spec)

* Update docs

* Update src/db/pool.cr

Co-authored-by: Beta Ziliani <beta@manas.tech>

* Use ConnectionBuilder instead of procs

* Fix inferred type when there is a single concrete connection type

* Update src/db/driver.cr

Co-authored-by: Beta Ziliani <beta@manas.tech>

---------

Co-authored-by: Beta Ziliani <beta@manas.tech>
2023-06-22 22:03:08 -03:00
Jamie Gaskins
65b926c926
Use https link for API docs (#180) 2023-05-29 17:47:21 -03:00
Brian J. Cardiff
da7494b5ba
Fix mt issues (#178) 2023-04-24 12:26:25 +02:00
Amaury Trujillo
87dc8aafaf
Add DuckDB driver to README (#172) 2022-10-27 18:36:46 +02:00
Jamie Gaskins
e076a08cd0
Close a transaction when returning from within its block (#167) 2022-10-27 18:35:57 +02:00
Jamie Gaskins
167b55966e
Allow the use of enums (#168) 2022-10-26 16:06:14 +02:00
Johannes Müller
07c68d38e4
Fix positional parameter warnings (#173) 2022-10-20 20:48:21 +02:00
Beta Ziliani
3e9ed7a304
Merge pull request #163 from crystal-lang/fix/crystal-1.4 2022-03-25 14:59:20 -03:00
Johannes Müller
c8a0849423
Fix specs for Crystal 1.4.0
The format of string conversion error messages was changed in
https://github.com/crystal-lang/crystal#11883
2022-03-23 21:25:21 +01:00
Brian J. Cardiff
e3f1a308b4
Release 0.11.0 (#157) 2022-01-27 10:56:35 -03:00
Brian J. Cardiff
27ade07359
Add workaround for crystal-lang/crystal#9483 (#160)
* Add workaround for crystal-lang/crystal#9483

* Update src/db/begin_transaction.cr

Co-authored-by: Johannes Müller <straightshoota@gmail.com>

Co-authored-by: Johannes Müller <straightshoota@gmail.com>
2022-01-22 15:06:16 -03:00
Brian J. Cardiff
d829b07b01
Returns block's value on #transaction method (#159)
* Returns block's value on #transaction method

* Update src/db/begin_transaction.cr

Co-authored-by: Johannes Müller <straightshoota@gmail.com>

Co-authored-by: Johannes Müller <straightshoota@gmail.com>
2022-01-21 10:57:14 -03:00
Johannes Müller
5a7d27e0c5
Improve DB::MappingException usage (#129) 2021-10-12 20:51:53 -03:00
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
Stephen von Takach
a25f33611c
feat(error): close resources on resource lost (#155) 2021-09-10 08:36:01 -03:00
Stephen von Takach
6dc3f2dd6f
fix(pool): returning closed resources to the pool (#154) 2021-09-06 19:02:43 -03:00
Duke Nguyen
bf5ca75d1a
Fix model.from_rs argument type typo (#142) 2021-08-05 00:12:59 -03:00
Johannes Müller
3a53a69f83
Update Github Actions config (#152)
Add explicit 1.0.0 to version matrix.

Formatter check should only run on latest.
2021-06-21 16:53:14 +02:00
Oleh Prypin
52bd5b0a86
Migrate continuous testing to GitHub Actions (#147)
* crystal tool format

* Migrate continuous testing to GitHub Actions
2021-06-08 20:52:00 -03:00
Brian J. Cardiff
0415deebbb
Release 0.10.1 (#149) 2021-03-22 17:18:00 -03:00
Jamie Gaskins
eaddae7d71
Add docs for DB::Database#setup_connection (#139) 2020-10-27 12:55:06 -03:00
Brian J. Cardiff
bd45602864
Release 0.10.0 (#136) 2020-09-30 10:37:37 -03:00
Brian J. Cardiff
284145138f
Bump required Crystal to 0.35.0 (#135)
In order to use logging we need 0.35.0
2020-09-29 10:35:14 -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
fad9e70353
Fix mutex deadlock in setup_connection (#128)
Adds auto_release = false in setup_connection to avoid trying to release
the connection to the pool before it has been added.
2020-09-14 10:55:18 -03:00
Jamie Gaskins
291b65b853
Allow DB::Pool to be used a generic connection pool (#131)
* Allow DB::Pool to be a generic connection pool

* Use fully qualified class name for consistency

Co-authored-by: Brian J. Cardiff <bcardiff@gmail.com>

* Wrap only the necessary code in an `ensure`

* Add spec for http client pool

* Fix ICE in crystal-sqlite3

Co-authored-by: Brian J. Cardiff <bcardiff@gmail.com>
2020-09-14 10:49:00 -03:00
Brian J. Cardiff
ed686ad301
Release 0.9.0 (#126) 2020-04-06 20:11:41 -03:00
Brian J. Cardiff
511fe20253
Use DB::NoResultsError on QueryMethods (#125) 2020-04-06 18:36:37 -03:00
Brian J. Cardiff
7543908733
Merge pull request #124 from crystal-lang/crystal/0.34.0
Crystal 0.34.0 support
2020-04-06 18:14:40 -03:00
Brian J. Cardiff
f4b298d3a5 Use select / timeout in Crystal 0.34 2020-04-02 12:34:27 -03:00
Brian J. Cardiff
af200eac54 Comply exhaustive case check
Comply exhaustive case check
2020-04-02 12:34:27 -03:00
Jeremy Woertink
f08a4da60a
Add NoResultsError (#121) 2020-02-17 22:04:23 +01:00
Brian J. Cardiff
f128d6ddf3
Update README.md and docs for dynamic args (#117) 2020-01-14 10:29:54 -03:00
Brian J. Cardiff
7e83f8e26c
Release 0.8.0 (#116) 2019-12-11 17:38:42 -03:00
Nick Clifford
e1832fc359 Add DB::Serializable (#115) 2019-10-31 11:34:23 -03:00
Brian J. Cardiff
2b95d69e68
Release 0.7.0 (#112) 2019-09-20 17:37:29 -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