Commit Graph

500 Commits

Author SHA1 Message Date
Martin Kleusberg
2b6153d9b8 Fix browse table settings not being reapplied correctly
We have already fixed the rowid column from appearing after almost every
action in the Browse Data tab, for example in commit
39302f5b60.

This didn't fix every issue related to this problem though. Hidden
columns are shown too and modified column widths are reset. Also this
happens for different actions, for example the column widths are also
reset when sorting the view or when changing the filters. All these
problems are hopefully fixed by this commit.

See issue #1475.
2018-08-10 13:52:39 +02:00
mgrojo
d3d9d10ecd Untranslatable message in SQL Log 2018-08-09 22:23:16 +02:00
Martin Kleusberg
8a07f0e655 Change page_size PRAGMA from spin box to combo box
Change the control of the page_size PRAGMA from a spin box to a combo
box in the Edit Pragma tab. This makes sure no values are entered which
aren't a power of two. The same change was done in the Cipher dialog a
while ago for the same reasons.
2018-08-09 14:39:34 +02:00
Martin Kleusberg
a23c0a0852 Fix PRAGMA view when loading a project file
When loading a project file which changes the foreign_keys or the
case_sensitive_like PRAGMAs while being in the Edit Pragma tab didn't
update the UI accordingly. Only after changing the tab and returning to
the Edit Pragma tab updated the controls.
2018-08-09 14:08:09 +02:00
Martin Kleusberg
c9d651c7b2 Add value of the case_sensitive_like PRAGMA to the project files
We allow the user to edit the case_senstive_like PRAGMA via the UI. But
because its state is not saved in the database - just like with the
foreign_key PRAGMA - we should save it in the project file for users who
want to restore the entire environment.
2018-08-09 14:04:47 +02:00
Manuel
4f1256cc5f Allow "getting" and setting case_sensitive_like pragma (#1494)
* Allow "getting" and setting case_sensitive_like pragma

In order to allow case insensitive filtering, the pragma
case_sensitive_like is added to the GUI. Given that this pragma cannot be
read, a special SELECT request is made in DBBrowserDB::getPragma for
inferring its value.

See issue #1489.

* Warning in the pragma case_sensitive_like

This pragma has some peculiarities, so it is convenient to warn the user
about it through a tool-tip in the value.
2018-08-09 14:00:21 +02:00
mgrojo
282e6739d9 Prevent data loss when editing table with foreign keys enabled
Our procedure for editing tables may involve a drop of the old table
definition. This will trigger the "ON DELETE CASCADE" clauses of the
child tables, leading to unexpected and silent data loss.

Following the procedure described in:
https://www.sqlite.org/lang_altertable.html
we can guarantee that no data is deleted, but at the cost of opening a
new transaction specific for the table modification. The possible pending
changes must be saved before. This is only done when the foreign_keys
pragma is enabled.

See issue #1481
2018-08-09 13:28:49 +02:00
Martin Kleusberg
9a8f223b88 Add support for in-memory databases
Add a new menu option for opening an in-memory database. When working on
an in-memory database some menu options are disabled because they only
make sense when the database is also written to disk. I have left the
Write Changes button enabled though because for some actions the current
transaction needs to be committed - even though it's only committed to
memory then.

See issues #335 and #1492.
2018-08-05 15:45:50 +02:00
mgrojo
d65427a8a6 Fixes and improvements in user messages
- Title for the File Extension Manager
- Independent messages for each object type. See issue #1490
- Fixed incorrect wording in "What's This" message
2018-08-03 18:49:25 +02:00
mgrojo
241372e6eb Improvements for the "Unlock view editing" feature
Provide a combo box for selecting the field from the list of fields in the
view.

Uncheck the menu option when the user cancels the action.

Escape the primary key in the UPDATE statements since it is not always
rowid (views, without rowid tables) and consequently the name might needed
it.
2018-07-29 18:18:19 +02:00
mgrojo
2701223aac Crash when browsing a table, deleting it and back to the data browser
Following these steps a crash was observed:
1. Browse a Table T in "Browse Data" tab
2. Change to "Database Structure" tab and delete table T
3. Return to "Browse Data" tab

The application crashed because the combo still had the deleted table
value. It was too soon for the updateInsertDeleteRecordButton() call.
Moving it to the end of the method solves the issue.
2018-07-29 14:27:28 +02:00
mgrojo
01bf059270 Fix style consistency and translation problems with "Delete record" label
In 5fbf5ca1b2 the label of the "Delete
Record" was inadvertently changed to "Delete record". The label is reverted
to the old style for consistency and for restoring coherence of the
translations.

The new Polish translation is changed accordingly.

See issue #1480.
2018-07-20 19:11:44 +02:00
mgrojo
d50a27ab6e Use exact filter when jumping to referenced row
Ctrl+Shift+Click jumps from a foreign key cell to its referenced row in the
other table. It is only exactly one row if we filter for equality. It will
be also faster.
2018-07-17 23:25:57 +02:00
Martin Kleusberg
aef3b6b0cc Rework execution logic in Execute SQL tab
This commit changes the execution logic in the Execute SQL tab. Before
this we were trying to first get the exact part of the SQL text to
execute and then execute it without further checking. After this we're
only trying to find an exact start position for the SQL text to execute
while the end position is only a rough estimate. This way the exact end
position can be determined by SQLite.

This fixes issue #1470.

It also cleans up the code a bit and (hopefully) makes it a bit easier
to read.
2018-07-12 22:24:42 +02:00
Manuel
96e44b9957 Merge pull request #1455 from sqlitebrowser/execute_sql_issues
User SQL log with results and other fixes and improvements in Execute SQL
2018-07-11 21:48:45 +02:00
mgrojo
606ec09b61 PR #1455: implement @MKleusberg's suggested changes
- The start and index is only manipulated for the special case of the
start position being at the end of a line (typical when the sentences begin
at the first column. This gives accurate results for both error indicators
and line references in log.

- Tab name in execution titles.

- 'IN' in titles instead of 'AT'.
2018-07-11 21:22:07 +02:00
Iulian Onofrei
3cdc65a63f Add automatic crypted databases open via dotenvs (#1404)
* Rename confusing variables

* Fix some project warnings

* Fix code style

* Add constant for the default page size

* Move KeyFormats enum to CipherSettings

* Fix code style

* Fix memory leak

* Stop relying on CipherDialog for encryption settings management

* Fix code style

* Add .env format for QSettings

* Add automatic crypted databases open via dotenvs

This adds support for `.env` files next to the crypted databases that
are to be opened that contains the needed cipher settings.

The only required one is the plain-text password as a value for the key
with the name of the database like this:

    myCryptedDatabase.sqlite = MyPassword

This way, databases with a different extension are supported too:

    myCryptedDatabase.db = MyPassword

You can also specify a custom page size adding a different line
(anywhere in the file) like this:

    myCryptedDatabase.db_pageSize = 2048

If not specified, `1024` is used.

You can also specify the format of the specified key using the
associated integer id:

    anotherCryptedDatabase.sqlite = 0xCAFEBABE
    anotherCryptedDatabase.sqlite_keyFormat = 1

where `1` means a Raw key. If not specified, `0` is used, which means a
simple text Passphrase.

Dotenv files (`.env`) are already used on other platforms and by
different tools to manage environment variables, and it's recommended
to be ignored from version control systems, so they won't leak.

* Add new files to CMakeLists

* Move DotenvFormat include to the implementation

* Fix build error

* Remove superfluous method

(related to ac51c23)

* Remove superfluous checks

* Fix memory leaks

(introduced by 94bbb46)

* Fix code style

* Make dotenv related variable and comment clearer

* Remove duplicated code

* Remove unused forward declaration

(introduced by e5a0293)
2018-07-10 20:46:17 +02:00
mgrojo
1130d0c89e Issue #1458: fix tab_sql save and loading in project files
This issue was introduced in 211f7341ff
(issue #1306).

browse_table_settings node was not closed, and consequently tab_sql node
was left inside tab_browse but the loading case for tab_sql was still
expecting it outside tab_browse. Since this was an unintended change the
tab_sql node is reverted now to its former location.

This means that all the nightly versions since
211f7341ff until this fix generate project
files with incorrect format and later versions will also not be able to
restore the SQL tabs for those project files unless manually edited.

Nevertheless, the loading code was also broken for tab_sql since there
was an incorrect skipCurrentElement call before getting to the tab_sql tag.
2018-07-07 17:58:35 +02:00
Manuel
719416e7e7 Merge pull request #1436 from sqlitebrowser/identifier_quotes
Preference for quoting identifier mechanism (issues #683 and #1280)
2018-06-30 18:15:29 +02:00
mgrojo
a45a7a39c1 Issue #1450: resize Name column in DB Schema tab to contents
Resize also the Name column in the Dock since it has usually short content
and there is little space there, so it's better to resize it after every
schema population.
2018-06-30 18:06:35 +02:00
mgrojo
6d44c6d412 User SQL log with results and other fixes and improvements in Execute SQL
## Enhancements
1.  Following suggestions in issue #1448, I've added the filename, line
references and results to the User log dock as comments. The same output
for the last query goes to the usual SQL results widget. The multiple
statement executions are therefore added while executing and not in a
block that might eventually not being executed.

2. I added a busy mouse cursor for giving hint to user when there is a query
in execution and when it has finished.

3. The cursor moves to the erroneous line if the query ends with error.

## Fixes

1. The error indicators where sometimes displaced. This was caused by
manipulations of the query before passing it to SQLite. Whitespace and
comments are discarded by SQLite, so it is better to just let it ignore
them. The only visible change seems that they might be recorded in the log or
or be decorated as error when they are adjacent to the next query.
Transaction bits are replaced by the same amount of spaces, so the
character indexing inside the query isn't perturbed.

2. The default case for the sqlite3_step has been changed to an error case
since all the possible non-error cases have already been treated.
Otherwise constraint errors in INSERT statements (for example) are not
indicated as errors, but the query execution ends anyway.
2018-06-30 14:13:54 +02:00
mgrojo
588363b7f6 Get the encoding name from a combo box in the "Set encoding" dialog
User can enter the encoding name with completion or select it from the
list using the mouse. This will help users to discover available codecs
and to find a suitable one in an easier way. This should help with encoding
issues like #1453.
2018-06-29 22:37:25 +02:00
mgrojo
98f4b88fd6 Issue #1450: adjust SQL Schema column in DB Schema dock to content
The SQL Schema column in DB Schema dock is set to resize automatically
to adjust to the content, like it is already done for the same column in
the Database Structure tab.
2018-06-25 20:52:30 +02:00
mgrojo
e11b32ed54 Issue #1432: Popup menu in "Open Database"
A popup menu has been added in the "Open Database" button. A normal click
selects the "Open Database..." action as before. A delayed click opens the
popup menu for selecting either the "Open Database..." action or the
"Open Database Read Only..." action.
2018-06-24 20:43:17 +02:00
mgrojo
01f0146bbe Reset SQL results table when the query has not returned data
When we know that the just executed query has not returned data, reset the
table results model, so the results view is also reset.

Added QAbstractItemModel::beginResetModel() and
QAbstractItemModel::endResetModel() to the model's reset method. This
resets completely the table view.

This improves the situation for #1431, without addressing the underlying
problem of not detecting correctly the type of query. In any case, any
query not returning data should reset the results from previous queries.
2018-06-21 11:52:46 +02:00
mgrojo
5c7238d3d0 Preference for quoting identifier mechanism
A new option is added to the SQL tab in Preferences for choosing which
quoting characters must be used by the application when it inserts an
identifier in SQL code. The three options supported by SQLite are
available.

Default quoting characters have been changed from `Grave accents` to
"Double quotes" (SQL standard).

This options also affect the highlighting of double quoted strings: when
the SQL standard is selected, double quoted expressions are highlighted as
identifiers, otherwise as literal strings.
2018-06-18 17:49:12 +02:00
Martin Kleusberg
115d1f185a Tweak enabling/disabling of insert and delete record buttons
Improve the enabling and disabling code for the insert and delete record
buttons in the Browse Data tab. With this the buttons should be enabled
if and only if they can actually be used. The commit also makes the code
easier to read because the final state of the buttons don't depend on
the call order of the involved functions anymore. Instead there is only
one function now which enables and disables them.

This also fixes one TODO in the multithreading patch.
2018-06-08 22:46:47 +02:00
Martin Kleusberg
3da520cdd1 Clean up multi threading patch, fix build and some bugs
Make strings translatable, remove some more debug code, fix tests,
reduce size of patch slightly, remove weird tooltip, don't crash when
closing database, simplify code, fix filters, don't link agains pthread
on Windows.
2018-06-08 22:46:47 +02:00
Martin Kleusberg
51dbe72e23 Multi-threading patch
This was done by Michael Krause.
https://lists.sqlitebrowser.org/pipermail/db4s-dev/2018-February/000305.html

In this commit I only fixed two compiler warnings, some whitespace
issues and removed some debug messages.
2018-06-08 22:46:47 +02:00
Martin Kleusberg
f51b44d8d7 Add support for deleting rows in views which are unlocked for editing
If a view has been unlocked for editing by specifiying a pseudo primary
key, with this commit you can now delete records from the view if an
appropriate trigger exists.

See issue #141.
2018-06-07 16:08:08 +02:00
Martin Kleusberg
ea25618f22 Don't ask for PK again when chaging back to a editing-enabled view
When unlocking a view for editing by specifying a pseudo-PK, then
switching to another table, and then coming back to the original view,
you would be asked again for the pseudo-PK even though it was stored.
The same applies when loading a project file for this case. This is
fixed by this commit.
2018-06-07 14:44:30 +02:00
Martin Kleusberg
72506fb902 Fix table view after unlocking view editing 2018-06-07 14:38:25 +02:00
mgrojo
e50022c11e Export to CSV the currently browsed data as displayed
A new option is added to the Browse Data tab toolbar for exporting the data
of the browsed table as currently displayed (after filters, display formats
and order column) to a CSV file. This is done in coherence to the same
popup options in the SQL tab for execution results.

See issue #1402
2018-06-02 01:04:55 +02:00
Martin Kleusberg
39302f5b60 Also fix rowid column being shown when changing the sort order
Apply the same fix as in 189b750a00 for
the filters for the sort order.
2018-05-25 23:47:47 +02:00
Martin Kleusberg
b647026051 Show warning when opening a project file with the old file format
Thanks to Iulian for idea!
2018-05-25 18:49:27 +02:00
Martin Kleusberg
189b750a00 Fix e6a4326e9b
Fix the fix for a Qt issue which messes up the table view when using the
filters. Without any fix, the rowid column is always shown when changing
the filters, but because the filter bar isn't regenerated the filters
are all displaced. With the first commit this is fixed, however changing
the filters always regenerated the filter bar which in turn deleted the
current filter value. With this commit this is fixed. The filters are
now working as expected.
2018-05-20 20:22:55 +02:00
GortiZ
e7752d7398 KUbuntu 14.04 support restored (#1298)
* - [NEW] Add new interface and functionality to manage database file extension. (Implements feature request #659)

* - [FIX] Fixed CMake file to src.pro

* - Applied changes requested by mgrojo to uniform code with sqlitebrowser standards
- Add "history" when closing editor window, but reopen before closing preferences
- Revert some changes done by QtCreator

* Refuse from previous commit

* Additional changes requested by MKleusberg:
- [CHG] Always add "All files (*)" to filters
- [FIX] Removed unused include

* merged from master

* Merge sqlitebrowser master

* [FIX] Fixed compatibility to compile on KUbuntu 14.04 with Qt 5.2.1

* [FIX] Fix Qt version for QOpenGLWidget support on previous commit

* [CHG] Uniformed QT_VERSION_CHECK style
[CHG] Reverted macOS check on Mainwindow for OpenGL context creation
2018-05-20 15:56:01 +02:00
Martin Kleusberg
4ab2bee2ac When selecting an entire row and deleting it, remove the record
When selecting an entire row or multiple entire rows in the table view
and hitting the delete key, delete the records and not just the cell
contents.

See issue #1391.
2018-05-20 13:22:13 +02:00
Karim ElDeeb
817de2d3f5 Update Report bug link to include the system information (#1388)
When reporting an issue from the application, via the menu 'Help | Bug report', the new link will add the label 'bug' and include the system information automatically.

See issue #1386
2018-05-16 19:01:13 +02:00
Martin Kleusberg
13d9f98aab Fix the text of the toolbar actions for deleting and modifying objects
When selecting an object other than a table the toolbar actions would
say "Modify/Delete Table" nonetheless. I don't remember it being this
way, so I suspect this was changed by updating to Qt 5. Either way, this
commit makes absolutely sure the texts are updated properly.
2018-05-16 18:39:51 +02:00
Martin Kleusberg
a5d36694db Simplify code 2018-05-16 18:26:48 +02:00
Martin Kleusberg
aebfc5151e No need to commit when setting defer_foreign_keys pragma
Don't commit the current transaction when setting the defer_foreign_keys
pragma in the Execute SQL tab. Not only isn't it required by SQLite but
it's quite contrary to the point of a pragma the purpose of which is
to change the current transaction.
2018-05-16 16:18:03 +02:00
Martin Kleusberg
e6a4326e9b Fix filters
Fix a bug that causes the rowid column to be always shown when changing
the filters. I *believe* this was happening since updating to Qt 5.10.
2018-05-16 15:01:22 +02:00
Karim ElDeeb
86960a5952 Update project links to HTTPS 2018-05-07 17:42:29 +02:00
mgrojo
211f7341ff New XML format for browse data table settings in project files
Browse data table settings are now saved in the project files using a pure
tagged XML format. This would make easier the generation of our project
files by external tools or direct human edition of the project files.

Compatibility with the older format is preserved in the loading. Previous
software versions have been tested with the new format, and they are also
able to load the new project files ignoring these new tags.

See related issue #1306
2018-03-03 20:06:49 +01:00
mgrojo
3277174cb1 Problems with WITHOUT ROWID tables
Quoted values in DELETE FROM and UPDATE SET take into account that value
could have a single quote and they are now doubled.

Detect tables without rowid in order to make invisible the "Show rowid
column"

See issue #1332
2018-02-28 23:18:49 +01:00
Martin Kleusberg
1110b87d95 Fix structure view after changing settings
This is fixing a follow-up issue of
012ad9217a.

See issue #1288.
2018-01-26 14:44:13 +01:00
mgrojo
7d1ddbd717 Preserve format in Copy Create Statement
The original Create statement formatting is preserved when the menu option
"Copy Create statement" is selected, regardless of the setting that removes
the line breaks in the schema view.

The Edit Role is requested to the model for getting the original text data.

See issue #1300
2018-01-18 20:59:02 +01:00
mgrojo
6a8c2e7a57 Revert "Preserve format in Copy Create Statement"
This reverts commit d1261146b3.
2018-01-18 20:35:08 +01:00
mgrojo
d1261146b3 Preserve format in Copy Create Statement
The original Create statement formatting is preserved when the menu option
"Copy Create statement" is selected, regardless of the setting that removes
the line breaks in the schema view.

The Edit Role is requested to the model for getting the original text data.

See issue #1300
2018-01-18 20:32:07 +01:00