ORM C++
Loading...
Searching...
No Matches
BackendRelations.cppm
Go to the documentation of this file.
1module;
2
3#include <memory>
4#include <optional>
5#include <string>
6#include <string_view>
7#include <vector>
8
9export module orm:backend_relations;
10
11import :foundation;
12import :model;
13import :expressions;
14import :sql;
15
16// database/postgresql/PostgresqlDialect.hpp
17export namespace orm::db::postgresql
18{
19
20class PostgresqlDialect final : public SqlDialect
21{
22public:
23 [[nodiscard]] auto quoteIdentifier(std::string_view identifier) const -> std::string override;
24 [[nodiscard]] auto bindMarker(std::string_view logicalName) const -> std::string override;
25 [[nodiscard]] auto toSqlType(model::ColumnType type,
26 std::optional<std::size_t> maxStringLength = std::nullopt) const
27 -> std::string override;
28 [[nodiscard]] auto renderCreateTablePrefix(std::string_view tableName, bool ifNotExists) const
29 -> std::string override;
30 [[nodiscard]] auto renderDropTable(std::string_view tableName, bool ifExists) const -> std::string override;
31 [[nodiscard]] auto renderAutoIncrementPrimaryKey(std::string_view columnName) const -> std::string override;
32 [[nodiscard]] auto renderPagination(const PaginationSpec& pagination) const -> std::string override;
33 [[nodiscard]] auto renderInsertIfAbsent(const InsertIfAbsentSpec& insert) const -> std::string override;
34 [[nodiscard]] auto renderAggregateResult(std::string_view expression, bool preserveExactNumeric) const
35 -> std::string override;
36};
37} // namespace orm::db::postgresql
38
39// database/postgresql/PostgresqlBackend.hpp
40export namespace orm::db::postgresql
41{
42
44{
45public:
48
49 [[nodiscard]] auto type() const noexcept -> BackendType override;
50 [[nodiscard]] auto capabilities() const noexcept -> const BackendCapabilities& override;
51 [[nodiscard]] auto dialect() const noexcept -> const SqlDialect& override;
52 [[nodiscard]] auto runtime() const noexcept -> const BackendRuntime& override;
53 [[nodiscard]] auto commandGenerator() const noexcept -> const CommandGenerator& override;
54 [[nodiscard]] auto compiledSqlFlavor() const noexcept -> CompiledSqlFlavor override;
55
56private:
57 BackendCapabilities backendCapabilities;
58 PostgresqlDialect postgresqlDialect;
59 std::unique_ptr<BackendRuntime> backendRuntime;
60 DefaultCommandGenerator postgresqlCommandGenerator;
61};
62} // namespace orm::db::postgresql
63
64// database/postgresql/PostgresqlTypeTranslator.hpp
65namespace orm::db::postgresql
66{
68{
69public:
70 [[nodiscard]] auto toSqlType(model::ColumnType type,
71 std::optional<std::size_t> maxStringLength = std::nullopt) const
72 -> std::string override;
73};
74} // namespace orm::db::postgresql
75
76// database/sqlite/SqliteDialect.hpp
77export namespace orm::db::sqlite
78{
79
80class SqliteDialect final : public SqlDialect
81{
82public:
83 [[nodiscard]] auto quoteIdentifier(std::string_view identifier) const -> std::string override;
84 [[nodiscard]] auto bindMarker(std::string_view logicalName) const -> std::string override;
85 [[nodiscard]] auto toSqlType(model::ColumnType type,
86 std::optional<std::size_t> maxStringLength = std::nullopt) const
87 -> std::string override;
88 [[nodiscard]] auto renderStringLengthConstraint(std::string_view columnName,
89 std::optional<std::size_t> maxStringLength) const
90 -> std::string override;
91 [[nodiscard]] auto renderCreateTablePrefix(std::string_view tableName, bool ifNotExists) const
92 -> std::string override;
93 [[nodiscard]] auto renderDropTable(std::string_view tableName, bool ifExists) const -> std::string override;
94 [[nodiscard]] auto renderAutoIncrementPrimaryKey(std::string_view columnName) const -> std::string override;
95 [[nodiscard]] auto renderPagination(const PaginationSpec& pagination) const -> std::string override;
96 [[nodiscard]] auto renderInsertIfAbsent(const InsertIfAbsentSpec& insert) const -> std::string override;
97};
98} // namespace orm::db::sqlite
99
100// database/sqlite/SqliteBackend.hpp
101export namespace orm::db::sqlite
102{
103
104class SqliteBackend final : public BackendProvider
105{
106public:
108 ~SqliteBackend() override;
109
110 [[nodiscard]] auto type() const noexcept -> BackendType override;
111 [[nodiscard]] auto capabilities() const noexcept -> const BackendCapabilities& override;
112 [[nodiscard]] auto dialect() const noexcept -> const SqlDialect& override;
113 [[nodiscard]] auto runtime() const noexcept -> const BackendRuntime& override;
114 [[nodiscard]] auto commandGenerator() const noexcept -> const CommandGenerator& override;
115 [[nodiscard]] auto compiledSqlFlavor() const noexcept -> CompiledSqlFlavor override;
116
117private:
118 BackendCapabilities backendCapabilities;
119 SqliteDialect sqliteDialect;
120 std::unique_ptr<BackendRuntime> backendRuntime;
121 DefaultCommandGenerator sqliteCommandGenerator;
122};
123} // namespace orm::db::sqlite
124
125// database/sqlite/SqliteTypeTranslator.hpp
126namespace orm::db::sqlite
127{
129{
130public:
131 [[nodiscard]] auto toSqlType(model::ColumnType type,
132 std::optional<std::size_t> maxStringLength = std::nullopt) const
133 -> std::string override;
134};
135}
136
137
138// database/mysql/MysqlDialect.hpp
139export namespace orm::db::mysql
140{
141
142class MysqlDialect final : public SqlDialect
143{
144public:
145 [[nodiscard]] auto quoteIdentifier(std::string_view identifier) const -> std::string override;
146 [[nodiscard]] auto bindMarker(std::string_view logicalName) const -> std::string override;
147 [[nodiscard]] auto toSqlType(model::ColumnType type,
148 std::optional<std::size_t> maxStringLength = std::nullopt) const
149 -> std::string override;
150 [[nodiscard]] auto renderCreateTablePrefix(std::string_view tableName, bool ifNotExists) const
151 -> std::string override;
152 [[nodiscard]] auto renderCreateTableSuffix() const -> std::string override;
153 [[nodiscard]] auto renderDefaultInsert(std::string_view tableName) const -> std::string override;
154 [[nodiscard]] auto renderDropTable(std::string_view tableName, bool ifExists) const -> std::string override;
155 [[nodiscard]] auto renderAutoIncrementPrimaryKey(std::string_view columnName) const -> std::string override;
156 [[nodiscard]] auto renderPagination(const PaginationSpec& pagination) const -> std::string override;
157 [[nodiscard]] auto renderInsertIfAbsent(const InsertIfAbsentSpec& insert) const -> std::string override;
158 [[nodiscard]] auto renderAggregateResult(std::string_view expression, bool preserveExactNumeric) const
159 -> std::string override;
160};
161} // namespace orm::db::mysql
162
163// database/mysql/MysqlBackend.hpp
164export namespace orm::db::mysql
165{
166
167class MysqlBackend final : public BackendProvider
168{
169public:
171 ~MysqlBackend() override;
172
173 [[nodiscard]] auto type() const noexcept -> BackendType override;
174 [[nodiscard]] auto capabilities() const noexcept -> const BackendCapabilities& override;
175 [[nodiscard]] auto dialect() const noexcept -> const SqlDialect& override;
176 [[nodiscard]] auto runtime() const noexcept -> const BackendRuntime& override;
177 [[nodiscard]] auto commandGenerator() const noexcept -> const CommandGenerator& override;
178 [[nodiscard]] auto compiledSqlFlavor() const noexcept -> CompiledSqlFlavor override;
179
180private:
181 BackendCapabilities backendCapabilities;
182 MysqlDialect mysqlDialect;
183 std::unique_ptr<BackendRuntime> backendRuntime;
184 DefaultCommandGenerator mysqlCommandGenerator;
185};
186} // namespace orm::db::mysql
187
188// database/mysql/MysqlTypeTranslator.hpp
189namespace orm::db::mysql
190{
192{
193public:
194 [[nodiscard]] auto toSqlType(model::ColumnType type,
195 std::optional<std::size_t> maxStringLength = std::nullopt) const
196 -> std::string override;
197};
198} // namespace orm::db::mysql
199
200// database/mariadb/MariadbDialect.hpp
201export namespace orm::db::mariadb
202{
203
204class MariadbDialect final : public SqlDialect
205{
206public:
207 [[nodiscard]] auto quoteIdentifier(std::string_view identifier) const -> std::string override;
208 [[nodiscard]] auto bindMarker(std::string_view logicalName) const -> std::string override;
209 [[nodiscard]] auto toSqlType(model::ColumnType type,
210 std::optional<std::size_t> maxStringLength = std::nullopt) const
211 -> std::string override;
212 [[nodiscard]] auto renderCreateTablePrefix(std::string_view tableName, bool ifNotExists) const
213 -> std::string override;
214 [[nodiscard]] auto renderCreateTableSuffix() const -> std::string override;
215 [[nodiscard]] auto renderDefaultInsert(std::string_view tableName) const -> std::string override;
216 [[nodiscard]] auto renderDropTable(std::string_view tableName, bool ifExists) const -> std::string override;
217 [[nodiscard]] auto renderAutoIncrementPrimaryKey(std::string_view columnName) const -> std::string override;
218 [[nodiscard]] auto renderPagination(const PaginationSpec& pagination) const -> std::string override;
219 [[nodiscard]] auto renderInsertIfAbsent(const InsertIfAbsentSpec& insert) const -> std::string override;
220 [[nodiscard]] auto renderAggregateResult(std::string_view expression, bool preserveExactNumeric) const
221 -> std::string override;
222};
223} // namespace orm::db::mariadb
224
225// database/mariadb/MariadbBackend.hpp
226export namespace orm::db::mariadb
227{
228
229class MariadbBackend final : public BackendProvider
230{
231public:
233 ~MariadbBackend() override;
234
235 [[nodiscard]] auto type() const noexcept -> BackendType override;
236 [[nodiscard]] auto capabilities() const noexcept -> const BackendCapabilities& override;
237 [[nodiscard]] auto dialect() const noexcept -> const SqlDialect& override;
238 [[nodiscard]] auto runtime() const noexcept -> const BackendRuntime& override;
239 [[nodiscard]] auto commandGenerator() const noexcept -> const CommandGenerator& override;
240 [[nodiscard]] auto compiledSqlFlavor() const noexcept -> CompiledSqlFlavor override;
241
242private:
243 BackendCapabilities backendCapabilities;
244 MariadbDialect mariadbDialect;
245 std::unique_ptr<BackendRuntime> backendRuntime;
246 DefaultCommandGenerator mariadbCommandGenerator;
247};
248} // namespace orm::db::mariadb
249
250// database/mariadb/MariadbTypeTranslator.hpp
251namespace orm::db::mariadb
252{
254{
255public:
256 [[nodiscard]] auto toSqlType(model::ColumnType type,
257 std::optional<std::size_t> maxStringLength = std::nullopt) const
258 -> std::string override;
259};
260} // namespace orm::db::mariadb
261
auto runtime() const noexcept -> const BackendRuntime &override
auto commandGenerator() const noexcept -> const CommandGenerator &override
auto capabilities() const noexcept -> const BackendCapabilities &override
auto type() const noexcept -> BackendType override
auto compiledSqlFlavor() const noexcept -> CompiledSqlFlavor override
auto dialect() const noexcept -> const SqlDialect &override
auto renderDropTable(std::string_view tableName, bool ifExists) const -> std::string override
auto toSqlType(model::ColumnType type, std::optional< std::size_t > maxStringLength=std::nullopt) const -> std::string override
auto quoteIdentifier(std::string_view identifier) const -> std::string override
auto renderCreateTableSuffix() const -> std::string override
auto renderAutoIncrementPrimaryKey(std::string_view columnName) const -> std::string override
auto renderInsertIfAbsent(const InsertIfAbsentSpec &insert) const -> std::string override
auto bindMarker(std::string_view logicalName) const -> std::string override
auto renderCreateTablePrefix(std::string_view tableName, bool ifNotExists) const -> std::string override
auto renderDefaultInsert(std::string_view tableName) const -> std::string override
auto renderAggregateResult(std::string_view expression, bool preserveExactNumeric) const -> std::string override
auto renderPagination(const PaginationSpec &pagination) const -> std::string override
auto toSqlType(model::ColumnType type, std::optional< std::size_t > maxStringLength=std::nullopt) const -> std::string override
auto runtime() const noexcept -> const BackendRuntime &override
auto commandGenerator() const noexcept -> const CommandGenerator &override
auto compiledSqlFlavor() const noexcept -> CompiledSqlFlavor override
auto type() const noexcept -> BackendType override
auto dialect() const noexcept -> const SqlDialect &override
auto capabilities() const noexcept -> const BackendCapabilities &override
auto renderCreateTablePrefix(std::string_view tableName, bool ifNotExists) const -> std::string override
auto renderAutoIncrementPrimaryKey(std::string_view columnName) const -> std::string override
auto renderInsertIfAbsent(const InsertIfAbsentSpec &insert) const -> std::string override
auto renderDropTable(std::string_view tableName, bool ifExists) const -> std::string override
auto toSqlType(model::ColumnType type, std::optional< std::size_t > maxStringLength=std::nullopt) const -> std::string override
auto bindMarker(std::string_view logicalName) const -> std::string override
auto renderAggregateResult(std::string_view expression, bool preserveExactNumeric) const -> std::string override
auto renderDefaultInsert(std::string_view tableName) const -> std::string override
auto renderPagination(const PaginationSpec &pagination) const -> std::string override
auto quoteIdentifier(std::string_view identifier) const -> std::string override
auto renderCreateTableSuffix() const -> std::string override
auto toSqlType(model::ColumnType type, std::optional< std::size_t > maxStringLength=std::nullopt) const -> std::string override
auto runtime() const noexcept -> const BackendRuntime &override
auto compiledSqlFlavor() const noexcept -> CompiledSqlFlavor override
auto dialect() const noexcept -> const SqlDialect &override
auto type() const noexcept -> BackendType override
auto capabilities() const noexcept -> const BackendCapabilities &override
auto commandGenerator() const noexcept -> const CommandGenerator &override
auto renderInsertIfAbsent(const InsertIfAbsentSpec &insert) const -> std::string override
auto renderDropTable(std::string_view tableName, bool ifExists) const -> std::string override
auto toSqlType(model::ColumnType type, std::optional< std::size_t > maxStringLength=std::nullopt) const -> std::string override
auto renderAggregateResult(std::string_view expression, bool preserveExactNumeric) const -> std::string override
auto bindMarker(std::string_view logicalName) const -> std::string override
auto quoteIdentifier(std::string_view identifier) const -> std::string override
auto renderPagination(const PaginationSpec &pagination) const -> std::string override
auto renderCreateTablePrefix(std::string_view tableName, bool ifNotExists) const -> std::string override
auto renderAutoIncrementPrimaryKey(std::string_view columnName) const -> std::string override
auto toSqlType(model::ColumnType type, std::optional< std::size_t > maxStringLength=std::nullopt) const -> std::string override
auto dialect() const noexcept -> const SqlDialect &override
auto capabilities() const noexcept -> const BackendCapabilities &override
auto runtime() const noexcept -> const BackendRuntime &override
auto compiledSqlFlavor() const noexcept -> CompiledSqlFlavor override
auto commandGenerator() const noexcept -> const CommandGenerator &override
auto type() const noexcept -> BackendType override
auto renderCreateTablePrefix(std::string_view tableName, bool ifNotExists) const -> std::string override
auto renderStringLengthConstraint(std::string_view columnName, std::optional< std::size_t > maxStringLength) const -> std::string override
auto toSqlType(model::ColumnType type, std::optional< std::size_t > maxStringLength=std::nullopt) const -> std::string override
auto quoteIdentifier(std::string_view identifier) const -> std::string override
auto renderPagination(const PaginationSpec &pagination) const -> std::string override
auto bindMarker(std::string_view logicalName) const -> std::string override
auto renderDropTable(std::string_view tableName, bool ifExists) const -> std::string override
auto renderAutoIncrementPrimaryKey(std::string_view columnName) const -> std::string override
auto renderInsertIfAbsent(const InsertIfAbsentSpec &insert) const -> std::string override
auto toSqlType(model::ColumnType type, std::optional< std::size_t > maxStringLength=std::nullopt) const -> std::string override
BackendType
Definition types.cppm:62
CompiledSqlFlavor
Definition types.cppm:83
consteval auto columnName()
Definition mapping.cppm:563