|
87 | 87 | (doseq [a (:accounts test)]
|
88 | 88 | (info "Creating table" table-name a)
|
89 | 89 | (j/execute! conn [(str "CREATE TABLE IF NOT EXISTS " table-name a
|
90 |
| - "(id INT NOT NULL PRIMARY KEY," |
| 90 | + "(id INT NOT NULL PRIMARY KEY," |
| 91 | + "account_id INT NOT NULL," |
91 | 92 | "balance INT NOT NULL)")])
|
92 | 93 | (info "Populating account" a)
|
93 | 94 | (sql/insert! conn (str table-name a)
|
94 | 95 | {:id 0
|
95 |
| - :balance (if (= a (first (:accounts test))) |
96 |
| - (:total-amount test) |
97 |
| - 0)}))))) |
| 96 | + :account_id a |
| 97 | + :balance 10}))))) |
98 | 98 | (assoc this :conn conn :node node))))
|
99 | 99 |
|
100 | 100 | (invoke! [this test op]
|
101 | 101 | (try
|
| 102 | + ; op struct example: {:type :invoke, :f :read, :process 0, :time 65183208864} |
102 | 103 | (case (:f op)
|
103 | 104 | :read
|
104 |
| - (->> (:accounts test) |
105 |
| - (map (fn [x] |
106 |
| - [x (->> (sql/query conn [(str "SELECT balance FROM " table-name |
107 |
| - x)] |
108 |
| - {:row-fn :BALANCE}) |
109 |
| - first)])) |
| 105 | + (->> (sql/query conn ["SELECT ACCOUNT_ID, BALANCE FROM ACCOUNTS0 UNION |
| 106 | + SELECT ACCOUNT_ID, BALANCE FROM ACCOUNTS1 UNION |
| 107 | + SELECT ACCOUNT_ID, BALANCE FROM ACCOUNTS2 UNION |
| 108 | + SELECT ACCOUNT_ID, BALANCE FROM ACCOUNTS3 UNION |
| 109 | + SELECT ACCOUNT_ID, BALANCE FROM ACCOUNTS4 UNION |
| 110 | + SELECT ACCOUNT_ID, BALANCE FROM ACCOUNTS5 UNION |
| 111 | + SELECT ACCOUNT_ID, BALANCE FROM ACCOUNTS6 UNION |
| 112 | + SELECT ACCOUNT_ID, BALANCE FROM ACCOUNTS7 UNION |
| 113 | + SELECT ACCOUNT_ID, BALANCE FROM ACCOUNTS8 UNION |
| 114 | + SELECT ACCOUNT_ID, BALANCE FROM ACCOUNTS9"]) |
| 115 | + (map (juxt :ACCOUNT_ID :BALANCE)) |
110 | 116 | (into (sorted-map))
|
111 |
| - (map (fn [[k {b :BALANCE}]] [k b])) |
112 |
| - (into {}) |
113 | 117 | (assoc op :type :ok, :value))
|
114 | 118 |
|
115 | 119 | :transfer
|
|
0 commit comments