yogthos / migratus

MIGRATE ALL THE THINGS!
647 stars 95 forks source link

Failure: Query returns results #149

Closed ghost closed 6 years ago

ghost commented 6 years ago

When trying to use the following migration file with [org.xerial/sqlite-jdbc "3.25.2-SNAPSHOT"] (needs https://github.com/xerial/sqlite-jdbc/issues/368) against an SQLite3 database, migratus aborts with an error: Failure: Query returns results

ALTER TABLE applications RENAME COLUMN logo TO logo_url;

When executing the same query in the sqlite3 CLI program, I see no "result" being printed:

sqlite>  ALTER TABLE applications RENAME COLUMN logo TO logo_url;
sqlite>

I would like to know how to prevent this error / how to discard the result.

ghost commented 6 years ago

This is the result of using clojure.java.jdbc in a REPL directly:

(require 'clojure.java.jdbc)
;;=> nil
(def db-spec {:dbtype "sqlite" :dbname "db.sqlite3"})
;;=> #'user/db-spec
(clojure.java.jdbc/query db-spec ["ALTER TABLE applications RENAME COLUMN logo_url TO logo"])
;;=> ()
yogthos commented 6 years ago

Would you happen to have a test project I can look at. It doesn't look like 3.25.2-SNAPSHOT is up in public Maven repos, what's the process for building it?

devurandom commented 6 years ago

Would you happen to have a test project I can look at.

No open source code, sadly.

It doesn't look like 3.25.2-SNAPSHOT is up in public Maven repos, what's the process for building it?

Two possibilites:

xerial commented 6 years ago

Just released sqlite-jdbc 3.25.2

devurandom commented 6 years ago

Just released sqlite-jdbc 3.25.2

Thanks a lot!

yogthos commented 6 years ago

Ok, I can reproduce the issue locally with the latest version. The problem seems to be with db-do-prepared throwing an error here. The error is reproducible by running the command directly:

(jdbc/db-do-prepared
  {:connection-uri "jdbc:sqlite:test.db"}
  "ALTER TABLE applications RENAME COLUMN logo TO logo_url")

I'll take a look at switching to db-do-commands instead.

yogthos commented 6 years ago

Just pushed out migratus 1.1.0 to Clojars with the fix, let me know if everything looks good.