Commit graph

234 commits

Author SHA1 Message Date
Brian J. Cardiff
47e7d826e8 Add connection retry logic to connection pool 2016-08-31 17:32:01 -03:00
Brian J. Cardiff
dbf7c94ef4 release references to resources in pool. 2016-08-31 14:45:32 -03:00
Brian J. Cardiff
598aca50af Merged branch feature/pool_statement into feature/pool 2016-08-30 16:42:23 -03:00
Brian J. Cardiff
9c9176608d avoid caching statements in pool_statement
Only the connections where it was prepared need to be cached.
The connections already have a statement cache based on the query
2016-08-30 16:40:52 -03:00
Brian J. Cardiff
f568e4506d add cache of pool statements per query
refactor/reuse connection statement cache
2016-08-30 16:20:18 -03:00
Brian J. Cardiff
09b3b4bc01 minor code cleanup 2016-08-30 15:22:27 -03:00
Brian J. Cardiff
75aa821f5f make Database return PoolStatement
create StatementMethods for common interface between Statement and PoolStatment.
2016-08-29 16:56:34 -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
6e94536a91 clean up forward declaration of Database and Statement 2016-08-29 16:48:59 -03:00
Brian J. Cardiff
8d891a5a4e changes needed due to 3c91978d36
add posibility to inspect availability of a resource in a pool (testing only)
allow access to internal connection pool of db (testing only)
2016-08-29 13:14:47 -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
bed461c01b allow connection initialization 2016-08-18 00:55:43 -03:00
Ary Borenszweig
b5112d9a48 Add ResultSet#column_names. Fixes #11 2016-07-17 21:50:52 -03:00
Ary Borenszweig
1a4622ee59 Allow passing named arguments to DB.mapping 2016-07-15 11:54:09 -03:00
Ary Borenszweig
1cce4685ff Make DB::Pool accept a block 2016-07-11 15:38:31 -03:00
Ary Borenszweig
fff67e86a0 Fix using_connection 2016-07-11 12:56:40 -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
Brian J. Cardiff
b8cabee956 surround waiting_resource counter with a mutex for future thread support. 2016-07-07 14:48:58 -03:00
Brian J. Cardiff
421996b952 resource pool implementation with
* max_pool_size
* initial_pool_size
* max_idle_pool_size
* checkout_timeout
configuration options
2016-07-05 15:21:39 -03:00
Brian J. Cardiff
8a913d1ef2 Merge pull request #2 from spalladino/feature/db-mapping
Database mapping macro
2016-07-04 13:05:08 -03:00
Santiago Palladino
9ca0b19d9e Support mappable classes in query_one and query_all methods 2016-07-04 12:46:45 -03:00
Santiago Palladino
99352d9d2d Remove unneeded typecast when advancing a column in mapping macro 2016-07-04 12:44:31 -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
7fcedc6711 Database mapping macro
Add `from_rs` method to class to load instances from a resultset. Inspired by YAML and JSON mapping macros.
2016-07-04 11:19:16 -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
Santiago Palladino
5773faaa5c Enumerate columns in result_set 2016-07-04 11:11:21 -03:00
Ary Borenszweig
344804dd79 Merge pull request #9 from crystal-lang/feature/simple_read
Require ResultSet to just implement `read`, optionally implementing `read(T.class)`. Fixes #5
2016-06-30 16:00:33 -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
Ary Borenszweig
038ffef33a Don't use tap so return value is that of yield 2016-06-29 16:54:16 -03:00
Ary Borenszweig
72431bb1d8 Make sure to release a statmenet in case of an exception 2016-06-29 15:08:53 -03:00
Ary Borenszweig
2fc3f66a00 Make sure to return the connection to the pool in case of an exception preparing a query 2016-06-29 15:01:26 -03:00
Brian J. Cardiff
22a5a41534 update readme 2016-06-27 14:11:54 -03:00
Brian J. Cardiff
61c4b03252 update README.md due to transfer to crystal-lang 2016-06-24 17:27:06 -03:00
Brian J. Cardiff
56f5bffe31 Update README.md 2016-06-24 10:59:33 -03:00
Brian J. Cardiff
6838784f7b fix #1. avoid marking as closed if do_close raise exception 2016-06-24 10:54:30 -03:00
Brian J. Cardiff
933014c1aa fix bug related to Slice(T).new(0). It was messing with the data in the stack 2016-06-23 22:36:34 -03:00
Brian J. Cardiff
b2da4f3f6e allow scalar to return custom types 2016-06-23 22:19:53 -03:00
Brian J. Cardiff
34ae9d5775 avoid messing with finalize cycle in Disposable.
ensure statements are closed when connection is closed
2016-06-23 22:07:59 -03:00
Brian J. Cardiff
f836bbfccb add Database#using_connection to get a connection from the pool and return it when work is done. 2016-06-23 17:27:30 -03:00
Brian J. Cardiff
22db7d1043 fixes #5. Merge branch 'feature/5-type-extensibility' 2016-06-23 15:12:20 -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
9f3f0a9836 #5 remove read_object. allow read / read? to receive any type 2016-06-21 12:10:09 -03:00
Brian J. Cardiff
0daa1c18d7 DRY DB::TYPES and DB::Any 2016-06-21 12:08:51 -03:00
Brian J. Cardiff
76e3a35d59 allow exec to receive any object arguments 2016-06-21 10:55:44 -03:00
Brian J. Cardiff
d4b2046a65 refactor and add specs for query without blocks 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
5b23114095 add ResultSet#read_object 2016-06-21 10:54:58 -03:00