Skip to content

Commit 0a93a46

Browse files
author
Pierre-Luc Gagné
committed
Rename temporal value types
1 parent da814e3 commit 0a93a46

12 files changed

Lines changed: 127 additions & 127 deletions

examples/basic_query.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct product {
4848
COLUMN_FIELD(price, double)
4949
COLUMN_FIELD(stock, uint32_t)
5050
COLUMN_FIELD(description, std::optional<ds_mysql::varchar_field<512>>)
51-
COLUMN_FIELD(created_at, ds_mysql::sql_datetime)
51+
COLUMN_FIELD(created_at, ds_mysql::datetime_type)
5252
};
5353

5454
// ===================================================================

examples/schema_generation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct user {
2525
COLUMN_FIELD(username, ds_mysql::varchar_field<64>)
2626
COLUMN_FIELD(email, ds_mysql::varchar_field<255>)
2727
COLUMN_FIELD(is_active, bool)
28-
COLUMN_FIELD(created_at, ds_mysql::sql_datetime)
28+
COLUMN_FIELD(created_at, ds_mysql::datetime_type)
2929
};
3030

3131
// ===================================================================
@@ -43,7 +43,7 @@ struct order_row {
4343
COLUMN_FIELD(status, ds_mysql::varchar_field<32>)
4444

4545
struct order_created_at_tag {};
46-
using created_at = ds_mysql::tagged_column_field<order_created_at_tag, ds_mysql::sql_datetime>;
46+
using created_at = ds_mysql::tagged_column_field<order_created_at_tag, ds_mysql::datetime_type>;
4747
created_at created_at_;
4848
};
4949

examples/tables_with_constraints.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ struct symbol {
2828
COLUMN_FIELD(name, std::optional<ds_mysql::varchar_field<255>>)
2929
COLUMN_FIELD(sector, std::optional<ds_mysql::varchar_field<255>>)
3030
COLUMN_FIELD(currency, std::optional<ds_mysql::varchar_field<32>>)
31-
COLUMN_FIELD(created_date, ds_mysql::sql_datetime)
32-
COLUMN_FIELD(last_updated_date, ds_mysql::sql_datetime)
31+
COLUMN_FIELD(created_date, ds_mysql::datetime_type)
32+
COLUMN_FIELD(last_updated_date, ds_mysql::datetime_type)
3333
};
3434

3535
// ===================================================================

lib/include/ds_mysql/column_field.hpp

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -416,193 +416,193 @@ struct base<std::optional<varchar_field<N>>> : column_field_tag {
416416
};
417417

418418
template <>
419-
struct base<sql_datetime> : column_field_tag {
420-
using value_type = sql_datetime;
419+
struct base<datetime_type> : column_field_tag {
420+
using value_type = datetime_type;
421421

422-
sql_datetime value{};
422+
datetime_type value{};
423423

424424
constexpr base() = default;
425425
base(sql_now_t) noexcept : value(sql_now_t{}) {
426426
}
427427
base(std::chrono::system_clock::time_point tp) noexcept : value(tp) {
428428
}
429-
base(sql_datetime v) noexcept : value(v) {
429+
base(datetime_type v) noexcept : value(v) {
430430
}
431431

432432
base& operator=(sql_now_t) noexcept {
433-
value = sql_datetime{sql_now_t{}};
433+
value = datetime_type{sql_now_t{}};
434434
return *this;
435435
}
436436
base& operator=(std::chrono::system_clock::time_point tp) noexcept {
437-
value = sql_datetime{tp};
437+
value = datetime_type{tp};
438438
return *this;
439439
}
440-
base& operator=(sql_datetime v) noexcept {
440+
base& operator=(datetime_type v) noexcept {
441441
value = v;
442442
return *this;
443443
}
444444

445-
[[nodiscard]] constexpr sql_datetime const& get() const noexcept {
445+
[[nodiscard]] constexpr datetime_type const& get() const noexcept {
446446
return value;
447447
}
448-
[[nodiscard]] constexpr sql_datetime& get() noexcept {
448+
[[nodiscard]] constexpr datetime_type& get() noexcept {
449449
return value;
450450
}
451451

452-
constexpr operator sql_datetime const&() const noexcept {
452+
constexpr operator datetime_type const&() const noexcept {
453453
return value;
454454
}
455-
constexpr operator sql_datetime&() noexcept {
455+
constexpr operator datetime_type&() noexcept {
456456
return value;
457457
}
458458
};
459459

460460
template <>
461-
struct base<std::optional<sql_datetime>> : column_field_tag {
462-
using value_type = std::optional<sql_datetime>;
461+
struct base<std::optional<datetime_type>> : column_field_tag {
462+
using value_type = std::optional<datetime_type>;
463463

464-
std::optional<sql_datetime> value{};
464+
std::optional<datetime_type> value{};
465465

466466
constexpr base() = default;
467467
constexpr base(std::nullopt_t) noexcept : value(std::nullopt) {
468468
}
469-
base(sql_now_t) noexcept : value(sql_datetime{sql_now_t{}}) {
469+
base(sql_now_t) noexcept : value(datetime_type{sql_now_t{}}) {
470470
}
471-
base(std::chrono::system_clock::time_point tp) noexcept : value(sql_datetime{tp}) {
471+
base(std::chrono::system_clock::time_point tp) noexcept : value(datetime_type{tp}) {
472472
}
473-
base(sql_datetime v) noexcept : value(std::move(v)) {
473+
base(datetime_type v) noexcept : value(std::move(v)) {
474474
}
475-
base(std::optional<sql_datetime> v) noexcept : value(std::move(v)) {
475+
base(std::optional<datetime_type> v) noexcept : value(std::move(v)) {
476476
}
477477

478478
constexpr base& operator=(std::nullopt_t) noexcept {
479479
value = std::nullopt;
480480
return *this;
481481
}
482482
constexpr base& operator=(sql_now_t) noexcept {
483-
value = sql_datetime{sql_now_t{}};
483+
value = datetime_type{sql_now_t{}};
484484
return *this;
485485
}
486486
constexpr base& operator=(std::chrono::system_clock::time_point tp) noexcept {
487-
value = sql_datetime{tp};
487+
value = datetime_type{tp};
488488
return *this;
489489
}
490-
constexpr base& operator=(sql_datetime v) noexcept {
490+
constexpr base& operator=(datetime_type v) noexcept {
491491
value = std::move(v);
492492
return *this;
493493
}
494-
constexpr base& operator=(std::optional<sql_datetime> v) noexcept {
494+
constexpr base& operator=(std::optional<datetime_type> v) noexcept {
495495
value = std::move(v);
496496
return *this;
497497
}
498498

499-
[[nodiscard]] constexpr std::optional<sql_datetime> const& get() const noexcept {
499+
[[nodiscard]] constexpr std::optional<datetime_type> const& get() const noexcept {
500500
return value;
501501
}
502-
[[nodiscard]] constexpr std::optional<sql_datetime>& get() noexcept {
502+
[[nodiscard]] constexpr std::optional<datetime_type>& get() noexcept {
503503
return value;
504504
}
505505

506-
constexpr operator std::optional<sql_datetime> const&() const noexcept {
506+
constexpr operator std::optional<datetime_type> const&() const noexcept {
507507
return value;
508508
}
509-
constexpr operator std::optional<sql_datetime>&() noexcept {
509+
constexpr operator std::optional<datetime_type>&() noexcept {
510510
return value;
511511
}
512512
};
513513

514514
template <>
515-
struct base<sql_timestamp> : column_field_tag {
516-
using value_type = sql_timestamp;
515+
struct base<timestamp_type> : column_field_tag {
516+
using value_type = timestamp_type;
517517

518-
sql_timestamp value{};
518+
timestamp_type value{};
519519

520520
constexpr base() = default;
521521
base(sql_now_t) noexcept : value(sql_now_t{}) {
522522
}
523523
base(std::chrono::system_clock::time_point tp) noexcept : value(tp) {
524524
}
525-
base(sql_timestamp v) noexcept : value(v) {
525+
base(timestamp_type v) noexcept : value(v) {
526526
}
527527

528528
base& operator=(sql_now_t) noexcept {
529-
value = sql_timestamp{sql_now_t{}};
529+
value = timestamp_type{sql_now_t{}};
530530
return *this;
531531
}
532532
base& operator=(std::chrono::system_clock::time_point tp) noexcept {
533-
value = sql_timestamp{tp};
533+
value = timestamp_type{tp};
534534
return *this;
535535
}
536-
base& operator=(sql_timestamp v) noexcept {
536+
base& operator=(timestamp_type v) noexcept {
537537
value = v;
538538
return *this;
539539
}
540540

541-
[[nodiscard]] constexpr sql_timestamp const& get() const noexcept {
541+
[[nodiscard]] constexpr timestamp_type const& get() const noexcept {
542542
return value;
543543
}
544-
[[nodiscard]] constexpr sql_timestamp& get() noexcept {
544+
[[nodiscard]] constexpr timestamp_type& get() noexcept {
545545
return value;
546546
}
547547

548-
constexpr operator sql_timestamp const&() const noexcept {
548+
constexpr operator timestamp_type const&() const noexcept {
549549
return value;
550550
}
551-
constexpr operator sql_timestamp&() noexcept {
551+
constexpr operator timestamp_type&() noexcept {
552552
return value;
553553
}
554554
};
555555

556556
template <>
557-
struct base<std::optional<sql_timestamp>> : column_field_tag {
558-
using value_type = std::optional<sql_timestamp>;
557+
struct base<std::optional<timestamp_type>> : column_field_tag {
558+
using value_type = std::optional<timestamp_type>;
559559

560-
std::optional<sql_timestamp> value{};
560+
std::optional<timestamp_type> value{};
561561

562562
constexpr base() = default;
563563
constexpr base(std::nullopt_t) noexcept : value(std::nullopt) {
564564
}
565-
base(sql_now_t) noexcept : value(sql_timestamp{sql_now_t{}}) {
565+
base(sql_now_t) noexcept : value(timestamp_type{sql_now_t{}}) {
566566
}
567-
base(std::chrono::system_clock::time_point tp) noexcept : value(sql_timestamp{tp}) {
567+
base(std::chrono::system_clock::time_point tp) noexcept : value(timestamp_type{tp}) {
568568
}
569-
base(sql_timestamp v) noexcept : value(std::move(v)) {
569+
base(timestamp_type v) noexcept : value(std::move(v)) {
570570
}
571-
base(std::optional<sql_timestamp> v) noexcept : value(std::move(v)) {
571+
base(std::optional<timestamp_type> v) noexcept : value(std::move(v)) {
572572
}
573573

574574
constexpr base& operator=(std::nullopt_t) noexcept {
575575
value = std::nullopt;
576576
return *this;
577577
}
578578
constexpr base& operator=(sql_now_t) noexcept {
579-
value = sql_timestamp{sql_now_t{}};
579+
value = timestamp_type{sql_now_t{}};
580580
return *this;
581581
}
582582
constexpr base& operator=(std::chrono::system_clock::time_point tp) noexcept {
583-
value = sql_timestamp{tp};
583+
value = timestamp_type{tp};
584584
return *this;
585585
}
586-
constexpr base& operator=(sql_timestamp v) noexcept {
586+
constexpr base& operator=(timestamp_type v) noexcept {
587587
value = std::move(v);
588588
return *this;
589589
}
590-
constexpr base& operator=(std::optional<sql_timestamp> v) noexcept {
590+
constexpr base& operator=(std::optional<timestamp_type> v) noexcept {
591591
value = std::move(v);
592592
return *this;
593593
}
594594

595-
[[nodiscard]] constexpr std::optional<sql_timestamp> const& get() const noexcept {
595+
[[nodiscard]] constexpr std::optional<timestamp_type> const& get() const noexcept {
596596
return value;
597597
}
598-
[[nodiscard]] constexpr std::optional<sql_timestamp>& get() noexcept {
598+
[[nodiscard]] constexpr std::optional<timestamp_type>& get() noexcept {
599599
return value;
600600
}
601601

602-
constexpr operator std::optional<sql_timestamp> const&() const noexcept {
602+
constexpr operator std::optional<timestamp_type> const&() const noexcept {
603603
return value;
604604
}
605-
constexpr operator std::optional<sql_timestamp>&() noexcept {
605+
constexpr operator std::optional<timestamp_type>&() noexcept {
606606
return value;
607607
}
608608
};
@@ -768,7 +768,7 @@ struct tagged_column_field : column_field<detail::column_name_from_tag<Tag>(), T
768768
* id id_;
769769
770770
* COLUMN_FIELD(created_at,
771-
* ::ds_mysql::sql_timestamp,
771+
* ::ds_mysql::timestamp_type,
772772
* ::ds_mysql::column_attr::default_current_timestamp,
773773
* ::ds_mysql::column_attr::on_update_current_timestamp)
774774
*

lib/include/ds_mysql/schema_generator.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ struct sql_type_name {
8787
}
8888
} else if constexpr (std::same_as<base_type, std::chrono::system_clock::time_point>) {
8989
return "DATETIME";
90-
} else if constexpr (std::same_as<base_type, sql_datetime>) {
90+
} else if constexpr (std::same_as<base_type, datetime_type>) {
9191
return "DATETIME";
92-
} else if constexpr (std::same_as<base_type, sql_timestamp>) {
92+
} else if constexpr (std::same_as<base_type, timestamp_type>) {
9393
return "TIMESTAMP";
94-
} else if constexpr (std::same_as<base_type, sql_time>) {
94+
} else if constexpr (std::same_as<base_type, time_type>) {
9595
return "TIME";
9696
} else {
9797
static_assert(false,
9898
"Unsupported type for SQL mapping. Supported: uint32_t, int32_t, uint64_t, "
9999
"int64_t, float, double, float_type<P,S>, double_type<P,S>, decimal_type<P,S>, "
100100
"bool, varchar_field<N>, text_field (TEXT), "
101101
"mediumtext_field (MEDIUMTEXT, MySQL), longtext_field (LONGTEXT, MySQL), "
102-
"std::chrono::system_clock::time_point, sql_datetime, sql_timestamp, sql_time, "
102+
"std::chrono::system_clock::time_point, datetime_type, timestamp_type, time_type, "
103103
"and their std::optional variants");
104104
}
105105
} // end else (not ColumnFieldType)

0 commit comments

Comments
 (0)