summary refs log tree commit diff stats
path: root/lib/statement.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-01-28 12:59:42 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-01-28 12:59:42 -0500
commita7645346293ed6a912c26d0c50b6f7943f1f3072 (patch)
treed4d144e03a5e2dfcebbad2692fa71e790719d8fd /lib/statement.h
parent6ba8989bbbd497f949a3e8b17abed1d0bd048347 (diff)
downloadverbly-a7645346293ed6a912c26d0c50b6f7943f1f3072.tar.gz
verbly-a7645346293ed6a912c26d0c50b6f7943f1f3072.tar.bz2
verbly-a7645346293ed6a912c26d0c50b6f7943f1f3072.zip
Restructured verb frame schema to be more queryable
Groups are much less significant now, and they no longer have a database
table, nor are they considered a top level object anymore. Instead of
containing their own role data, that data is folded into the frames so
that it's easier to query; as a result, each group has its own copy of
the frames that it contains. Additionally, parts are considered top
level objects now, and you can query for frames based on attributes of
their indexed parts. Synrestrs are also contained in their own table
now, so that parts can be filtered against their synrestrs; they are
however not considered top level objects.

Created a new type of field, the "join where" or "condition join" field,
which is a normal join field that has a built in condition on a
specified field. This is used to allow creating multiple distinct join
fields from one object to another. This is required for the lemma::form
and frame::part joins, because filters for forms of separate inflections
should not be coalesced; similarly, filters on differently indexed frame
parts should not be coalesced.

Queries can now be ordered, ascending or descending, by a field, in
addition to randomly as before. This is necessary for accessing the
parts of a verb frame in the correct order, but may be useful to an end
user as well.

Fixed a bug with statement generation in that condition groups were not
being surrounded in parentheses, which made mixing OR groups and AND
groups generate inaccurate statements. This has been fixed;
additionally, parentheses are not placed around the top level condition,
and nested condition groups with the same logic type are coalesced, to
make query strings as easy to read as possible.

Also simplified the form::lemma field; it no longer conditions on the
inflection of the form like the lemma::form field does.

Also added a debug flag to statement::getQueryString that makes it
return a query string with all of the bindings filled in, for debug use
only.
Diffstat (limited to 'lib/statement.h')
-rw-r--r--lib/statement.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/statement.h b/lib/statement.h index aa56568..15c4ac3 100644 --- a/lib/statement.h +++ b/lib/statement.h
@@ -13,13 +13,14 @@
13namespace verbly { 13namespace verbly {
14 14
15 class filter; 15 class filter;
16 class order;
16 17
17 class statement { 18 class statement {
18 public: 19 public:
19 20
20 statement(object context, filter queryFilter); 21 statement(object context, filter queryFilter);
21 22
22 std::string getQueryString(std::list<std::string> select, bool random, int limit) const; 23 std::string getQueryString(std::list<std::string> select, order sortOrder, int limit, bool debug = false) const;
23 24
24 std::list<binding> getBindings() const; 25 std::list<binding> getBindings() const;
25 26
@@ -153,10 +154,12 @@ namespace verbly {
153 154
154 // Utility 155 // Utility
155 156
156 std::string toSql() const; 157 std::string toSql(bool toplevel, bool debug = false) const;
157 158
158 std::list<binding> flattenBindings() const; 159 std::list<binding> flattenBindings() const;
159 160
161 condition flatten() const;
162
160 private: 163 private:
161 union { 164 union {
162 struct { 165 struct {
@@ -246,8 +249,8 @@ namespace verbly {
246 { 249 {
247 return (context == object::notion) ? "notions" 250 return (context == object::notion) ? "notions"
248 : (context == object::word) ? "words" 251 : (context == object::word) ? "words"
249 : (context == object::group) ? "groups"
250 : (context == object::frame) ? "frames" 252 : (context == object::frame) ? "frames"
253 : (context == object::part) ? "parts"
251 : (context == object::lemma) ? "lemmas_forms" 254 : (context == object::lemma) ? "lemmas_forms"
252 : (context == object::form) ? "forms" 255 : (context == object::form) ? "forms"
253 : (context == object::pronunciation) ? "pronunciations" 256 : (context == object::pronunciation) ? "pronunciations"