entity query builder progress
This commit is contained in:
@@ -12,4 +12,33 @@ std::ostream &operator<<(std::ostream &out, const field &col)
|
||||
return out;
|
||||
}
|
||||
|
||||
bool field::is_integer() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool field::is_floating_point() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool field::is_bool() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool field::is_string() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool field::is_blob() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool field::is_null() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+2
-9
@@ -52,10 +52,10 @@ bool record::has_primary_key() const
|
||||
return pk_index_ > -1;
|
||||
}
|
||||
|
||||
const column_definition &record::primary_key() const
|
||||
std::optional<column_definition> record::primary_key() const
|
||||
{
|
||||
if (!has_primary_key()) {
|
||||
throw std::logic_error("record has no primary key");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return columns_[pk_index_];
|
||||
@@ -63,16 +63,9 @@ const column_definition &record::primary_key() const
|
||||
|
||||
const column_definition &record::at(const column &col) const
|
||||
{
|
||||
auto ref = columns_by_name_.at(col.name).first;
|
||||
return columns_by_name_.at(col.name).first;
|
||||
}
|
||||
|
||||
//const column_definition &record::at(const std::string &name) const
|
||||
//{
|
||||
// auto ref = columns_by_name_.at(name).first;
|
||||
// return columns_by_name_.at(name).first;
|
||||
//}
|
||||
|
||||
const column_definition &record::at(size_t index) const
|
||||
{
|
||||
return columns_.at(index);
|
||||
|
||||
+1
-11
@@ -5,16 +5,6 @@
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
void table_info::create(connection &conn, schema &scm) const
|
||||
{
|
||||
conn.query(scm).create().table(name, prototype.columns()).execute();
|
||||
}
|
||||
|
||||
void table_info::drop(connection &conn, schema &scm) const
|
||||
{
|
||||
conn.query(scm).drop().table(name).execute();
|
||||
}
|
||||
|
||||
schema::schema(std::string name)
|
||||
: name_(std::move(name)) {}
|
||||
|
||||
@@ -44,7 +34,7 @@ std::pair<std::string, std::string> schema::reference(const std::type_index &ti)
|
||||
if (!it->second.prototype.has_primary_key()) {
|
||||
throw std::logic_error("table doesn't has primary key");
|
||||
}
|
||||
return { it->second.name, it->second.prototype.primary_key().name() };
|
||||
return { it->second.name, it->second.prototype.primary_key().value().name() };
|
||||
}
|
||||
|
||||
return {};
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ void session::create_schema()
|
||||
{
|
||||
auto c = pool_.acquire();
|
||||
for (const auto &t : *schema_) {
|
||||
t.second.create(*c, *schema_);
|
||||
c->query(*schema_).create().table(t.second.name, t.second.prototype.columns()).execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user