Skip to content

Commit

Permalink
SqlTraits: drop ColumnTypeName(...)
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Parpart <[email protected]>
  • Loading branch information
christianparpart committed Jan 5, 2025
1 parent 9db364f commit dd7dc01
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions src/Lightweight/SqlTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ struct SqlTraits
std::string_view PrimaryKeyAutoIncrement; // Maybe rename this to `PrimaryKeyIdentityColumnType`?
std::string_view CurrentTimestampExpr;
size_t MaxStatementLength {};
std::function<std::string_view(SqlColumnType)> ColumnTypeName;
};

namespace detail
Expand All @@ -99,83 +98,31 @@ namespace detail
inline SqlTraits const MicrosoftSqlTraits {
.PrimaryKeyAutoIncrement = "INT IDENTITY(1,1) PRIMARY KEY",
.CurrentTimestampExpr = "GETDATE()",
.ColumnTypeName = [](SqlColumnType value) -> std::string_view {
switch (value)
{
case SqlColumnType::TEXT:
return "VARCHAR(MAX)";
case SqlColumnType::BOOLEAN:
return "BIT";
case SqlColumnType::GUID:
return "UNIQUEIDENTIFIER";
default:
return DefaultColumnTypeName(value);
}
},
};

inline SqlTraits const PostgresSqlTraits {
.PrimaryKeyAutoIncrement = "SERIAL PRIMARY KEY",
.CurrentTimestampExpr = "CURRENT_TIMESTAMP",
.ColumnTypeName = [](SqlColumnType value) -> std::string_view {
switch (value)
{
case SqlColumnType::GUID:
return "UUID";
case SqlColumnType::DATETIME:
return "TIMESTAMP";
default:
return detail::DefaultColumnTypeName(value);
}
},
};

inline SqlTraits const OracleSqlTraits {
.PrimaryKeyAutoIncrement = "NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY PRIMARY KEY",
.CurrentTimestampExpr = "SYSTIMESTAMP",
.ColumnTypeName = [](SqlColumnType value) -> std::string_view {
switch (value)
{
case SqlColumnType::DATETIME:
return "TIMESTAMP";
case SqlColumnType::GUID:
return "RAW(16)";
case SqlColumnType::SMALLINT:
return "NUMBER";
case SqlColumnType::INTEGER:
return "NUMBER";
case SqlColumnType::BIGINT:
return "NUMBER";
default:
return detail::DefaultColumnTypeName(value);
}
},
};

inline SqlTraits const SQLiteTraits {
.PrimaryKeyAutoIncrement = "INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT",
.CurrentTimestampExpr = "CURRENT_TIMESTAMP",
.ColumnTypeName = [](SqlColumnType value) -> std::string_view {
switch (value)
{
case SqlColumnType::GUID:
return "GUID";
default:
return detail::DefaultColumnTypeName(value);
}
},
};

inline SqlTraits const MySQLTraits {
.PrimaryKeyAutoIncrement = "INT AUTO_INCREMENT PRIMARY KEY",
.CurrentTimestampExpr = "NOW()",
.ColumnTypeName = detail::DefaultColumnTypeName,
};

inline SqlTraits const UnknownSqlTraits {
.PrimaryKeyAutoIncrement = "",
.CurrentTimestampExpr = "",
.ColumnTypeName = detail::DefaultColumnTypeName,
};

} // namespace detail
Expand Down

0 comments on commit dd7dc01

Please sign in to comment.