Skip to content

Commit

Permalink
fixes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
tamizhvendan committed Oct 31, 2024
1 parent 5df5489 commit 16adc0d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* 1.0.4 - 2024-10-31
- Fixes #15
* 1.0.3 - 2024-07-26
- Updated docs
* 1.0.2 - 2024-01-02
Expand All @@ -8,5 +10,4 @@
- Removed unused functions
- Bumped dependencies to their latest versions
* 1.0.1 -- 2023-11-21
- Adding type hints for metadata generation. Credits [
Dekel Pilli](https://github.com/tamizhvendan/honeyeql/pull/10)
- Adding type hints for metadata generation. Credits [Dekel Pilli](https://github.com/tamizhvendan/honeyeql/pull/10)
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.tamizhvendan</groupId>
<artifactId>honeyeql</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>

<name>Honey EQL</name>
<description>HoneyEQL enables you to query database using the EQL.</description>
Expand All @@ -21,7 +21,7 @@
<url>https://github.com/tamizhvendan/honeyeql</url>
<connection>scm:git:git://github.com/tamizhvendan/honeyeql.git</connection>
<developerConnection>scm:git:ssh://[email protected]/tamizhvendan/honeyeql.git</developerConnection>
<tag>1.0.3</tag>
<tag>1.0.4</tag>
</scm>

<dependencies>
Expand Down
15 changes: 9 additions & 6 deletions src/honeyeql/mutation.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
(defn- entity-name [entity]
(-> entity keys first namespace))

(defn- table-name [entity]
(-> (entity-name entity) (str/replace #"-" "_") keyword))
(defn- table-name [{:keys [heql-meta-data]} entity]
(->> entity
keys
first
(heql-md/entity-relation-ident heql-meta-data)))

(defn- sqlize-entity [db-adapter entity]
(into {}
Expand All @@ -25,7 +28,7 @@
(namespacify-attributes
(entity-name entity)
(sql/insert! (:db-spec db-adapter)
(table-name entity)
(table-name db-adapter entity)
(sqlize-entity db-adapter entity)
{:column-fn (db/table-fn db-adapter)
:table-fn (db/table-fn db-adapter)
Expand All @@ -40,21 +43,21 @@
(map
#(namespacify-attributes first-entity-name %)
(sql/insert-multi! (:db-spec db-adapter)
(table-name first-entity)
(table-name db-adapter first-entity)
(keys (first sqlized-entities))
(map vals sqlized-entities)
{:column-fn (db/table-fn db-adapter)
:table-fn (db/table-fn db-adapter)
:builder-fn rs/as-kebab-maps})))))

(defn update! [db-adapter update-params where-params]
(sql/update! (:db-spec db-adapter) (table-name update-params)
(sql/update! (:db-spec db-adapter) (table-name db-adapter update-params)
(sqlize-entity db-adapter update-params) (sqlize-entity db-adapter where-params)
{:column-fn (db/table-fn db-adapter)
:table-fn (db/table-fn db-adapter)}))

(defn delete! [db-adapter where-params]
(sql/delete! (:db-spec db-adapter) (table-name where-params)
(sql/delete! (:db-spec db-adapter) (table-name db-adapter where-params)
(sqlize-entity db-adapter where-params)
{:column-fn (db/table-fn db-adapter)
:table-fn (db/table-fn db-adapter)}))

0 comments on commit 16adc0d

Please sign in to comment.