Commit Graph

11 Commits

Author SHA1 Message Date
jdb 3e19b3628d Use a connection provider rather than long-lived connections.
The previous implementation expected to work with a context object that
contained a field `conn` that represented a valid database connection.
However, this required the caller to manage the connection's lifecycle
(close, renew, etc.). Now we expect to receive a context object that
provides a `withConn` procedure or template that accepts a statement
block and provides a `conn` variable to that code block. For example:

    createRecord(db: DbContext): Record =
        # withConn must be defined for DbContext
        db.withConn:
          # conn must be injected into the statement block context
          conn.exec(sql("INSERT INTO..."))

In addition, this change provides a connection pooling mechanism
(`DbConnPool`) as a default implementation for this hypothetical
DbContext. There is also a new function `initPool` that will create an
DbConnPool instance.

Callers of this library can modify their DbContext objects to extend
DbConnPool or simply be a type alias of DbConnPool.
2022-02-07 11:38:37 -06:00
jdb 8aad3cdb79 Make the logging namespace GC-safe. 2022-01-22 20:23:30 -06:00
jdb f7791b6f60 Add logging statments (behind namespaced logger). 2022-01-13 16:22:15 -06:00
jdb 279d9aa7fd Expose a number of useful utility methods and macros. 2021-08-02 05:54:56 -05:00
jdb d90372127b Further fix for ISO8601 date parsing.
Recognize versions of timestamps with 'T' as the date/time separator.
For example, compare:

    '2021-08-01 23:14:00-05:00'
    '2021-08-01T23:14:00-05:00'

This commit adds support for the second flavor (and it's variations).
2021-08-01 23:14:18 -05:00
jdb 2b78727356 Fix for PostgreSQL timestamp with timezone fields.
The previous fix for PostgreSQL timestamp fields matched fields with and
without timezones, but did not properly parse values from fields that
included the timezone. Now we check for the presence of the timezone in
the date string and choose a format string to parse it correctly.
2021-07-05 11:24:06 -05:00
jdb ff0c5e5305 Update to support Nim 1.4.x+ 2021-04-02 13:58:08 -05:00
jdb bdd62cad66 Add support for float data type. 2020-02-16 21:50:43 -06:00
jdb b496b10578 Bump version number for 0.2.0 release. 2020-02-09 04:22:59 -06:00
jdb 56a257be2e Bump package version. 2019-12-25 20:36:03 -06:00
jdb 35af299fdc Rename module from 'fiber_orm_nim' to 'fiber_orm'. 2019-12-25 18:51:00 -06:00