Update use of fmt to support fmtlib-10
This commit is contained in:
parent
481e172424
commit
45598bb7c8
|
@ -13,12 +13,11 @@
|
|||
#include "schema.hpp"
|
||||
|
||||
#include <cruft/util/introspection/enum_simple.hpp>
|
||||
#include <cruft/util/iterator/infix.hpp>
|
||||
#include <cruft/util/format/quoted.hpp>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ostream.h>
|
||||
|
||||
#include <iomanip>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
|
@ -26,7 +25,7 @@
|
|||
std::ostream&
|
||||
cruft::db::runtime::operator<< (std::ostream &os, type const val)
|
||||
{
|
||||
fmt::print (os, "{}", std::quoted (cruft::introspection::to_string (val)));
|
||||
fmt::print (os, "{}", cruft::format::quoted (cruft::introspection::to_string (val)));
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@ -37,7 +36,7 @@ cruft::db::runtime::operator<< (std::ostream &os, column const &val)
|
|||
{
|
||||
fmt::print (os,
|
||||
R"({{ "name": {}, "type": {} }})",
|
||||
std::quoted (val.name),
|
||||
cruft::format::quoted (val.name),
|
||||
val.type_
|
||||
);
|
||||
return os;
|
||||
|
@ -51,8 +50,8 @@ cruft::db::runtime::operator<< (std::ostream &os, table const &val)
|
|||
fmt::print (
|
||||
os,
|
||||
R"({{ "name": {}, "columns": [{}] }})",
|
||||
std::quoted (val.name),
|
||||
cruft::iterator::make_infix (val.columns)
|
||||
cruft::format::quoted (val.name),
|
||||
fmt::join (val.columns, ", ")
|
||||
);
|
||||
|
||||
return os;
|
||||
|
@ -66,7 +65,7 @@ cruft::db::runtime::operator<< (std::ostream &os, schema const &val)
|
|||
fmt::print (
|
||||
os,
|
||||
R"({{ "tables": [{}] }})",
|
||||
cruft::iterator::make_infix (val.tables)
|
||||
fmt::join (val.tables, ", ")
|
||||
);
|
||||
|
||||
return os;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include <iosfwd>
|
||||
|
||||
#include <fmt/ostream.h>
|
||||
|
||||
|
||||
namespace cruft::db::runtime {
|
||||
std::ostream& operator<< (std::ostream &os, type const val);
|
||||
|
@ -19,3 +21,9 @@ namespace cruft::db::runtime {
|
|||
std::ostream& operator<< (std::ostream &os, table const &val);
|
||||
std::ostream& operator<< (std::ostream &os, schema const &val);
|
||||
}
|
||||
|
||||
|
||||
template <> struct fmt::formatter<cruft::db::runtime::type> : fmt::ostream_formatter {};
|
||||
template <> struct fmt::formatter<cruft::db::runtime::column> : fmt::ostream_formatter {};
|
||||
template <> struct fmt::formatter<cruft::db::runtime::table> : fmt::ostream_formatter {};
|
||||
template <> struct fmt::formatter<cruft::db::runtime::schema> : fmt::ostream_formatter {};
|
||||
|
|
|
@ -17,13 +17,16 @@
|
|||
|
||||
#include <cruft/util/iterator/infix.hpp>
|
||||
#include <cruft/util/adapter.hpp>
|
||||
#include <cruft/util/format/quoted.hpp>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/ostream.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <variant>
|
||||
#include <ranges>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -191,11 +194,9 @@ print_sql (
|
|||
fmt::print (os,
|
||||
"CREATE TYPE {} AS ENUM ({});",
|
||||
obj.name,
|
||||
cruft::iterator::make_infix (
|
||||
cruft::adapter::container::transform (
|
||||
cruft::view (obj.values),
|
||||
[] (auto const &i) { return std::quoted (i); }
|
||||
)
|
||||
fmt::join (
|
||||
obj.values | std::views::transform ([] (auto const &i) { return cruft::format::quoted (i); }),
|
||||
", "
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -215,7 +216,7 @@ print_sql (
|
|||
obj.unique and not obj.primary ? "UNIQUE" : "",
|
||||
obj.name,
|
||||
obj.table,
|
||||
cruft::iterator::make_infix (obj.columns)
|
||||
fmt::join (obj.columns, ", ")
|
||||
);
|
||||
return os;
|
||||
}
|
||||
|
@ -231,9 +232,9 @@ print_sql (
|
|||
fmt::print (os,
|
||||
"ALTER TABLE {} ADD CONSTRAINT FOREIGN KEY ({}) REFERENCES {} ({});",
|
||||
obj.table,
|
||||
cruft::iterator::make_infix (obj.our_columns),
|
||||
fmt::join (obj.our_columns, ", "),
|
||||
obj.their_table,
|
||||
cruft::iterator::make_infix (obj.their_columns)
|
||||
fmt::join (obj.their_columns, ", ")
|
||||
);
|
||||
|
||||
return os;
|
||||
|
@ -250,7 +251,7 @@ print_sql (
|
|||
fmt::print (os,
|
||||
"ALTER TABLE {} ADD CONSTRAINT UNIQUE ({});",
|
||||
obj.table,
|
||||
cruft::iterator::make_infix (obj.columns)
|
||||
fmt::join (obj.columns, ", ")
|
||||
);
|
||||
|
||||
return os;
|
||||
|
@ -267,7 +268,7 @@ print_sql (
|
|||
fmt::print (os,
|
||||
"ALTER TABLE {} ADD CONSTRAINT PRIMARY ({});",
|
||||
obj.table,
|
||||
cruft::iterator::make_infix (obj.columns)
|
||||
fmt::join (obj.columns, ", ")
|
||||
);
|
||||
|
||||
return os;
|
||||
|
|
Loading…
Reference in New Issue