diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-02-15 10:01:00 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-02-15 10:01:00 -0500 |
commit | e5d8d42eae6ce486678d87e33c1a7c26e2a6c1a1 (patch) | |
tree | ed93f2d04e5cc5a3c1764d2613a910504d81084d | |
parent | 10edf7e99adddc2952d41fffd4de51a03bb70612 (diff) | |
download | verbly-e5d8d42eae6ce486678d87e33c1a7c26e2a6c1a1.tar.gz verbly-e5d8d42eae6ce486678d87e33c1a7c26e2a6c1a1.tar.bz2 verbly-e5d8d42eae6ce486678d87e33c1a7c26e2a6c1a1.zip |
Added antogram and antophone querying
-rw-r--r-- | lib/field.h | 18 | ||||
-rw-r--r-- | lib/form.cpp | 1 | ||||
-rw-r--r-- | lib/form.h | 1 | ||||
-rw-r--r-- | lib/pronunciation.cpp | 1 | ||||
-rw-r--r-- | lib/pronunciation.h | 1 | ||||
-rw-r--r-- | lib/statement.cpp | 4 |
6 files changed, 19 insertions, 7 deletions
diff --git a/lib/field.h b/lib/field.h index f799900..93dab97 100644 --- a/lib/field.h +++ b/lib/field.h | |||
@@ -85,7 +85,7 @@ namespace verbly { | |||
85 | object joinWith, | 85 | object joinWith, |
86 | bool nullable = false) | 86 | bool nullable = false) |
87 | { | 87 | { |
88 | return field(obj, type::join, name, nullable, 0, joinWith); | 88 | return field(obj, type::join, name, nullable, 0, joinWith, name); |
89 | } | 89 | } |
90 | 90 | ||
91 | static field joinField( | 91 | static field joinField( |
@@ -94,7 +94,7 @@ namespace verbly { | |||
94 | const char* table, | 94 | const char* table, |
95 | bool nullable = false) | 95 | bool nullable = false) |
96 | { | 96 | { |
97 | return field(obj, type::join, name, nullable, table); | 97 | return field(obj, type::join, name, nullable, table, obj, name); |
98 | } | 98 | } |
99 | 99 | ||
100 | static field joinWhere( | 100 | static field joinWhere( |
@@ -105,7 +105,7 @@ namespace verbly { | |||
105 | int conditionValue, | 105 | int conditionValue, |
106 | bool nullable = false) | 106 | bool nullable = false) |
107 | { | 107 | { |
108 | return field(obj, type::join_where, name, nullable, 0, joinWith, 0, 0, 0, conditionColumn, conditionValue); | 108 | return field(obj, type::join_where, name, nullable, 0, joinWith, name, 0, 0, conditionColumn, conditionValue); |
109 | } | 109 | } |
110 | 110 | ||
111 | static field joinThrough( | 111 | static field joinThrough( |
@@ -153,6 +153,14 @@ namespace verbly { | |||
153 | return field(obj, type::join_through, name, true, joinTable, obj, name, joinColumn, foreignJoinColumn); | 153 | return field(obj, type::join_through, name, true, joinTable, obj, name, joinColumn, foreignJoinColumn); |
154 | } | 154 | } |
155 | 155 | ||
156 | static field selfJoin( | ||
157 | object obj, | ||
158 | const char* name, | ||
159 | const char* foreignColumn) | ||
160 | { | ||
161 | return field(obj, type::join, name, true, 0, obj, foreignColumn); | ||
162 | } | ||
163 | |||
156 | static field hierarchalSelfJoin( | 164 | static field hierarchalSelfJoin( |
157 | object obj, | 165 | object obj, |
158 | const char* name, | 166 | const char* name, |
@@ -220,9 +228,9 @@ namespace verbly { | |||
220 | const char* getForeignColumn() const | 228 | const char* getForeignColumn() const |
221 | { | 229 | { |
222 | // We ignore hierarchal joins because they are always self joins. | 230 | // We ignore hierarchal joins because they are always self joins. |
223 | return ((type_ == type::join_through) || (type_ == type::join_through_where)) | 231 | return ((type_ == type::join) || (type_ == type::join_through) || (type_ == type::join_through_where)) |
224 | ? foreignColumn_ | 232 | ? foreignColumn_ |
225 | : throw std::domain_error("Only many-to-many join fields have a foreign column"); | 233 | : throw std::domain_error("Only join fields have a foreign column"); |
226 | } | 234 | } |
227 | 235 | ||
228 | const char* getJoinColumn() const | 236 | const char* getJoinColumn() const |
diff --git a/lib/form.cpp b/lib/form.cpp index 18b495d..eeb940a 100644 --- a/lib/form.cpp +++ b/lib/form.cpp | |||
@@ -20,6 +20,7 @@ namespace verbly { | |||
20 | const field form::pronunciations = field::joinThrough(object::form, "form_id", object::pronunciation, "forms_pronunciations", "pronunciation_id"); | 20 | const field form::pronunciations = field::joinThrough(object::form, "form_id", object::pronunciation, "forms_pronunciations", "pronunciation_id"); |
21 | 21 | ||
22 | const field form::anagrams = field::joinField(object::form, "anagram_set_id", object::form); | 22 | const field form::anagrams = field::joinField(object::form, "anagram_set_id", object::form); |
23 | const field form::antogram = field::selfJoin(object::form, "reverse_form_id", "form_id"); | ||
23 | 24 | ||
24 | const field form::merographs = field::selfJoin(object::form, "form_id", "merography", "merograph_id", "holograph_id"); | 25 | const field form::merographs = field::selfJoin(object::form, "form_id", "merography", "merograph_id", "holograph_id"); |
25 | const field form::holographs = field::selfJoin(object::form, "form_id", "merography", "holograph_id", "merograph_id"); | 26 | const field form::holographs = field::selfJoin(object::form, "form_id", "merography", "holograph_id", "merograph_id"); |
diff --git a/lib/form.h b/lib/form.h index fb6b733..8ac6a02 100644 --- a/lib/form.h +++ b/lib/form.h | |||
@@ -163,6 +163,7 @@ namespace verbly { | |||
163 | static const field pronunciations; | 163 | static const field pronunciations; |
164 | 164 | ||
165 | static const field anagrams; | 165 | static const field anagrams; |
166 | static const field antogram; | ||
166 | 167 | ||
167 | static const field merographs; | 168 | static const field merographs; |
168 | static const field holographs; | 169 | static const field holographs; |
diff --git a/lib/pronunciation.cpp b/lib/pronunciation.cpp index b039da8..8bf34fd 100644 --- a/lib/pronunciation.cpp +++ b/lib/pronunciation.cpp | |||
@@ -19,6 +19,7 @@ namespace verbly { | |||
19 | const field pronunciation::rhyme = field::stringField(object::pronunciation, "rhyme", true); | 19 | const field pronunciation::rhyme = field::stringField(object::pronunciation, "rhyme", true); |
20 | 20 | ||
21 | const field pronunciation::anaphones = field::joinField(object::pronunciation, "anaphone_set_id", object::pronunciation); | 21 | const field pronunciation::anaphones = field::joinField(object::pronunciation, "anaphone_set_id", object::pronunciation); |
22 | const field pronunciation::antophone = field::selfJoin(object::pronunciation, "reverse_pronunciation_id", "pronunciation_id"); | ||
22 | 23 | ||
23 | const field pronunciation::merophones = field::selfJoin(object::pronunciation, "pronunciation_id", "merophony", "merophone_id", "holophone_id"); | 24 | const field pronunciation::merophones = field::selfJoin(object::pronunciation, "pronunciation_id", "merophony", "merophone_id", "holophone_id"); |
24 | const field pronunciation::holophones = field::selfJoin(object::pronunciation, "pronunciation_id", "merophony", "holophone_id", "merophone_id"); | 25 | const field pronunciation::holophones = field::selfJoin(object::pronunciation, "pronunciation_id", "merophony", "holophone_id", "merophone_id"); |
diff --git a/lib/pronunciation.h b/lib/pronunciation.h index 210d61d..b3625bd 100644 --- a/lib/pronunciation.h +++ b/lib/pronunciation.h | |||
@@ -149,6 +149,7 @@ namespace verbly { | |||
149 | static const field forms; | 149 | static const field forms; |
150 | 150 | ||
151 | static const field anaphones; | 151 | static const field anaphones; |
152 | static const field antophone; | ||
152 | 153 | ||
153 | static const field merophones; | 154 | static const field merophones; |
154 | static const field holophones; | 155 | static const field holophones; |
diff --git a/lib/statement.cpp b/lib/statement.cpp index 6e9e920..eb734dd 100644 --- a/lib/statement.cpp +++ b/lib/statement.cpp | |||
@@ -420,7 +420,7 @@ namespace verbly { | |||
420 | topTable_, | 420 | topTable_, |
421 | clause.getField().getColumn(), | 421 | clause.getField().getColumn(), |
422 | withInstName, | 422 | withInstName, |
423 | clause.getField().getColumn()); | 423 | clause.getField().getForeignColumn()); |
424 | 424 | ||
425 | // All CTEs have to be in the main statement, so integrate any | 425 | // All CTEs have to be in the main statement, so integrate any |
426 | // CTEs that our subquery uses. Also, retrieve the table mapping, | 426 | // CTEs that our subquery uses. Also, retrieve the table mapping, |
@@ -450,7 +450,7 @@ namespace verbly { | |||
450 | topTable_, | 450 | topTable_, |
451 | clause.getField().getColumn(), | 451 | clause.getField().getColumn(), |
452 | std::move(joinTable), | 452 | std::move(joinTable), |
453 | clause.getField().getColumn()); | 453 | clause.getField().getForeignColumn()); |
454 | 454 | ||
455 | // Integrate the subquery's table mappings, joins, and CTEs into | 455 | // Integrate the subquery's table mappings, joins, and CTEs into |
456 | // this statement, and return the subquery condition as our | 456 | // this statement, and return the subquery condition as our |