Skip to content

Commit 9cb7ec2

Browse files
author
Pierre-Luc Gagné
committed
Update docs and changelog for temporal types
- CHANGELOG: document time_type addition and sql_datetime/sql_timestamp breaking rename to datetime_type/timestamp_type - README: add temporal types to Features list and new Temporal Types section in Key API - DEVELOPMENT.md: add datetime_type/timestamp_type/time_type helpers to the sql_type_format reference - QUICKREF.md: add sql_temporal.hpp to Key Headers table
1 parent 0a93a46 commit 9cb7ec2

4 files changed

Lines changed: 38 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
### Added
12+
13+
- `time_type` — maps to SQL `TIME`; wraps a `std::chrono::microseconds` duration with optional
14+
fractional-second precision (0–6). Supports `INSERT`/`UPDATE` serialization and `SELECT`
15+
deserialization, including negative durations.
16+
17+
### Changed
18+
19+
- **Breaking:** Renamed temporal value types to align with the `float_type` / `double_type` /
20+
`decimal_type` naming scheme introduced in v1.1.0:
21+
- `sql_datetime``datetime_type`
22+
- `sql_timestamp``timestamp_type`
23+
1124
---
1225

1326
## [1.1.0] - 2026-03-23

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ DSMySQL provides a **header-only** library for building type-safe SQL queries an
1414
- **Zero-overhead abstractions** — all query building happens at compile time
1515
- **Strong types**`host_name`, `database_name`, `port_number`, `varchar_field<N>`, etc.
1616
- **Optional support**`std::optional<T>` maps to nullable SQL columns automatically
17+
- **Temporal types**`datetime_type`, `timestamp_type`, and `time_type` map to MySQL
18+
`DATETIME`, `TIMESTAMP`, and `TIME`; `sql_now` sentinel resolves to `NOW()`
19+
- **Numeric precision wrappers**`float_type`, `double_type`, and `decimal_type` with
20+
optional `<precision>` and `<precision, scale>` overrides
1721

1822
## Quick Start
1923

@@ -250,6 +254,23 @@ if (!r) std::println(stderr, "Mismatch: {}", r.error());
250254
auto r2 = db.validate_database<my_db>();
251255
```
252256

257+
### Temporal Types
258+
259+
```cpp
260+
struct event {
261+
COLUMN_FIELD(id, uint32_t)
262+
COLUMN_FIELD(created_at, datetime_type) // DATETIME — defaults to NOW()
263+
COLUMN_FIELD(updated_at, timestamp_type) // TIMESTAMP — defaults to NOW()
264+
COLUMN_FIELD(duration, time_type) // TIME
265+
COLUMN_FIELD(started_at, std::optional<datetime_type>) // nullable DATETIME
266+
};
267+
268+
// Fractional-second precision (0–6) is set on the value object:
269+
event row;
270+
row.created_at_ = datetime_type{tp, 3}; // DATETIME(3)
271+
row.duration_ = time_type{std::chrono::milliseconds{1500}, 3}; // TIME(3) = 00:00:01.500
272+
```
273+
253274
### Numeric Precision Overrides
254275
255276
```cpp

docs/DEVELOPMENT.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ Available helpers:
8787
- `sql_type_format::float_type()` / `float_type(p)` / `float_type(p, s)`
8888
- `sql_type_format::double_type()` / `double_type(p)` / `double_type(p, s)`
8989
- `sql_type_format::decimal_type()` / `decimal_type(p)` / `decimal_type(p, s)`
90+
- `sql_type_format::datetime_type()` / `datetime_type(fsp)``DATETIME` / `DATETIME(fsp)`
91+
- `sql_type_format::timestamp_type()` / `timestamp_type(fsp)``TIMESTAMP` / `TIMESTAMP(fsp)`
92+
- `sql_type_format::time_type()` / `time_type(fsp)``TIME` / `TIME(fsp)`
9093

9194
## Useful Commands
9295

docs/QUICKREF.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ DSMySQL/
5252
| `ds_mysql/database.hpp` | MySQL connection & queries |
5353
| `ds_mysql/sql.hpp` | SQL query builder |
5454
| `ds_mysql/sql_extension.hpp` | MySQL-specific extensions |
55+
| `ds_mysql/sql_temporal.hpp` | Temporal types: `datetime_type`, `timestamp_type`, `time_type` |
5556
| `ds_mysql/metadata.hpp` | MySQL information_schema types |
5657
| `ds_mysql/column_field.hpp` | Typed column descriptors |
5758
| `ds_mysql/schema_generator.hpp` | Schema generation |

0 commit comments

Comments
 (0)