New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attached Database Doesn't Attach If It Doesn't Contain Tables #1132

Closed
chrisjlocke opened this Issue Sep 12, 2017 · 11 comments

Comments

Projects
None yet
3 participants
@chrisjlocke
Copy link
Contributor

chrisjlocke commented Sep 12, 2017

Details for the issue

Addmittedly an odd case, but I thought I'd report it.
I'd attached two databases, and moved one table from one database to the other database. Worked fine. Saved both. This meant database 1 was now empty, as its tables had been moved.
Closing the databases and trying to attach the now empty database didn't work. DB4S asked what I'd want to call the attached database*, but it didn't appear in the 'Database Schema' tree. Additionally, if I clicked on 'Create Table', it only listed 'main' and 'temp' for a schema - the attached database didn't attach.
If it has to fail (no tables, indices, etc) then a message informing the user would be handy, with maybe (now I'm going too far....) an option to open that database instead (maybe in a different copy of DB4S?) so the attach could then be retried?

* As an additional issue/suggestion, would DB4S be able to pre-populate the 'Enter a name for the database' textbox with the filename of the database you just attached (sans extension).

If a name isn't given for an attached database, DB4S assumes Cancel has been clicked, rather than inform the user that they can't enter nothing. Again, some warning might be handy. (or disable the OK box if the textbox is empty)

Sorry for multiple issues per issue (if that makes sense...) but I didn't want to stuff up the issues screen with related issues...

Useful extra information

I'm opening this issue because:

  • DB4S is crashing
  • DB4S has a bug
  • DB4S needs a feature
  • DB4S has another problem

I'm using DB4S on:

  • Windows: ( version: ___ )
  • Linux: ( distro: ___ )
  • Mac OS: ( version: ___ )
  • Other: ___

I'm using DB4S version:

  • 3.10.99 (nightly from 12 Sep)
  • 3.10.0-beta*
  • 3.9.1
  • Other: ___

I have also:

@justinclift

This comment has been minimized.

Copy link
Member

justinclift commented Sep 12, 2017

Another good catch @chrisjlocke. 😄

The prepopulation thing is a good idea too. Should be super simple to get that done.

@justinclift justinclift added the bug label Sep 12, 2017

MKleusberg added a commit that referenced this issue Oct 5, 2017

Also remember databases with no objects
When attaching a database that is empty, i.e. has no objects in it,
include it in the schema map, too.

See issue #1132.

MKleusberg added a commit that referenced this issue Oct 5, 2017

MKleusberg added a commit that referenced this issue Oct 5, 2017

Allow empty names for attached databases
An empty database name is not the same as pressing the cancel button
when attaching a database.

See issue #1132.
@MKleusberg

This comment has been minimized.

Copy link
Member

MKleusberg commented Oct 5, 2017

Thanks, @chrisjlocke! These are all good ideas 😃

I've just pushed a number of commits which should fix all problems mentioned in this issue: attaching empty databases should work fine now, the attach name dialog is now prepopulated, and an empty database name is not longer the same as clicking the cancel button.

SQLite is weird enough to allow empty names for attached database, so for now we allow it too even though it just doesn't look like a good idea to do that (but I'm sure, like it's always the case, there's somebody somewhere out there who actually uses this 'feature').

@chrisjlocke

This comment has been minimized.

Copy link
Contributor Author

chrisjlocke commented Oct 6, 2017

✔Attaching blank databases
✔Suggest schema name
✔Attaching database with no name

♫ Another one bites the dust.... ♫

@chrisjlocke chrisjlocke closed this Oct 6, 2017

@chrisjlocke chrisjlocke reopened this Oct 6, 2017

@chrisjlocke

This comment has been minimized.

Copy link
Contributor Author

chrisjlocke commented Oct 6, 2017

❗ If you attach a database with a blank name, you cannot use it in SQL queries. Well, you can but I don't know how.

So attaching a database with no name gives the 'users' table a '.' prefix.

image

How is this used in the SQL window?

image
image

I've tried ".users", `.users` and '.users'.

@MKleusberg

This comment has been minimized.

Copy link
Member

MKleusberg commented Oct 6, 2017

Try ""."users" 😄

@MKleusberg

This comment has been minimized.

Copy link
Member

MKleusberg commented Oct 6, 2017

And yeah this is just stupid but as far as I remember SQLite allows empty table names and empty field names too. So this could execute just fine:

SELECT "" FROM ""."" WHERE ""="";

Edit: What a shame, it doesn't - at least not as expected 😦 SQLite evaluates the ""="" bit as always true because it's treated as a string comparison, not as a column name and a string.

@chrisjlocke

This comment has been minimized.

Copy link
Contributor Author

chrisjlocke commented Oct 6, 2017

Try ""."users"

But thats nuts! 😕 Wow. Thanks for pointing it out though!

@chrisjlocke chrisjlocke closed this Oct 6, 2017

@MKleusberg

This comment has been minimized.

Copy link
Member

MKleusberg commented Oct 6, 2017

It makes sense insofar as your schema name is empty-string and "" represents an empty string but yeah... I agree.

@chrisjlocke

This comment has been minimized.

Copy link
Contributor Author

chrisjlocke commented Oct 6, 2017

Aah, that actually makes sense now you've explained it like that. I was assuming the . was 'part' of the name. So "{schema}"."{table name}" - penny drops.

@MKleusberg

This comment has been minimized.

Copy link
Member

MKleusberg commented Oct 6, 2017

Ahh, I see what you were trying 😄 And yes, the dot it just a separator between schema and table name 😄

@chrisjlocke

This comment has been minimized.

Copy link
Contributor Author

chrisjlocke commented Oct 6, 2017

Me for the rest of the day:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment