Age | Commit message (Collapse) | Author |
|
Work in progress.
Ruby's `system` and `exec` don't load shell aliases, so the executables
defined in `EXECUTABLE_NAME` will always be the ones used to launch
database shells.
The trouble is, users might have installed the command with a different
name (as in "mysql5"), or they might not have the command on their path
(as in my case when using Postgres.app).
Apparently you can use an interactive or login shell to get aliases
(using the `-l` or `-i` flags, which do slightly different things,
sourcing .profile and .bashrc separately). Here's what I was following:
http://stackoverflow.com/questions/12060863/python-subprocess-call-a-bash-alias/25099813#25099813
Unfortunately I haven't been able to get it to work. Dropping this for
now.
|
|
Turns out the port actually did need to be a string, contrary to what I
had assumed in e89275bc787ae17bc698ac8cdb8cdaf5ebeb7852. I ended up with
this error when passing a specific port in a real test:
$ bake dbshell
rake aborted!
TypeError: no implicit conversion of Fixnum into String
.../lib/dbshell/client/postgres.rb:8:in `exec'
.../lib/dbshell/client/postgres.rb:8:in `runshell'
.../lib/dbshell/client/database.rb:24:in `runshell'
.../lib/dbshell/rails/tasks/dbshell.rake:6:in `block in <top (required)>'
.../versions/2.3.3/bin/bundle:22:in `load'
.../versions/2.3.3/bin/bundle:22:in `<main>'
Tasks: TOP => dbshell
|
|
PostGIS is, for our purposes, no different from Postgres. Both should
launch `psql`.
|
|
* Create a `.runshell()` method in `DBShell::Client::MySQL`
* Delegate to that class & method from `DBShell::Client::Database`
|
|
Tried this out with MySQL, and got this error since I haven't integrated
it yet. It struck me that "Invalid" doesn't make any sense. Really it's
something that is possible to do but that our gem doesn't support, so we
should be clearer about that fact.
|
|
For now only includes a `.build_command()` method.
Inspired again by:
https://github.com/django/django/blob/66150f7cf61bc09547fa98586790df596eff6d77/django/db/backends/mysql/client.py
although in our case we haven't handled some of the more exotic options.
Eventually we'll probably have to do that.
|
|
To match the 'sqlite3' gem's and the SQLite project's capitalisation
convention.
|
|
Now that we have a `Client` module
(46b019abd520870ab159b60c03c45675f64dd88a), it makes so much more sense
to put this error class inside it.
|
|
Update our class names to reflect the new file structure introduced in
b700c1bef89a67a64f1040fb6bb03c0320eefe91.
Use the
module DBShell
module Client
end
end
syntax intead of `DBShell::Client` so that we don't have to define the
`Client` module in a separate file and require it. Otherwise we'd get an
error:
lib/dbshell/client/sqlite3.rb:1:in `<top (required)>': uninitialized constant DBShell::Client (NameError)
|
|
Change the paths in the code to conform to the new file layout
introduced in b700c1bef89a67a64f1040fb6bb03c0320eefe91.
|
|
Will be modifying the class names in the next commit. Here we change the
file names & locations of the database client files.
The format changes thusly:
<adapter>_client.rb -> client/<adapter>.rb
This organisation feels cleaner to me. Wasn't liking the previous
structure.
|
|
A more generic interface to specific database adapter clients. This
class will act as a frontend to the others.
Calling its `.runshell()` will call the appropriate `.runshell()` for
the adapter provided in `connection_params`.
This way, we have a single entry point to start a database shell from
the Rake `dbshell` task.
|
|
Much simpler `.build_command` than the Postgres version. Only building
arguments now. Want to try out executing the subprocess command.
Inspired of course by:
https://github.com/django/django/blob/66150f7cf61bc09547fa98586790df596eff6d77/django/db/backends/sqlite3/client.py
|
|
Match the expected type with the input.
|
|
Forgot to add an `it` block for my test, which resulted in it failing
with a non-obvious error message.
|
|
Make an empty container to pass the basic tests.
|
|
Thinking up an interface for generating command line arguments for the
`psql` command. Based on Django's dbshell:
https://github.com/django/django/blob/66150f7cf61bc09547fa98586790df596eff6d77/tests/dbshell/test_postgresql_psycopg2.py
|