Commit Graph

2750 Commits

Author SHA1 Message Date
Martin Kleusberg 6cde3f51ad When modifying a view use DROP VIEW IF EXISTS instead of just DROP VIEW
Clicking on Edit View in the database structure tab opens a new SQL tab
with a DROP VIEW statement to delete the existing view and a copy of the
CREATE VIEW statement used for the current view. When the user modifies
the CREATE VIEW statement introduces an error in it, and then executes
the statements, the view is deleted and an error reported. Fixing that
error and re-running the script then fails at the DROP VIEW statement.
This means it makes more sense to make it a DROP VIEW IF EXISTS
statement.

See issue #2661.
2021-05-23 11:08:46 +02:00
Martin Kleusberg bbfaca2e06 Use LIMIT + OFFSET when generating SELECT statements instead
Instead of constructing queries using the LIMIT offset,limit notation
use the LIMIT limit OFFSET offset style.

See https://www.sqlite.org/lang_select.html#limitoffset.
2021-05-22 10:35:07 +02:00
Martin Kleusberg 3be5969bca Do not always refresh the table browser dock when opening a database
It does not seem like there is a good reason to always refresh the table
browser dock (there is always exactly one at this point) when opening a
database file, even when it is not visible. This only generates
unnecessary queries to the database.
2021-05-22 10:28:49 +02:00
Martin Kleusberg f56288023b dbhub: Avoid ambiguous F5 shortcut
Remove the F5 shortcut for refreshing the DBHub.io remote databases
because it is ambiguous and can make the main view not work as expected.
Since the refresh action is not super important in the DBHub.io dock any
way it is probably best to just remove the shortcut there.

See issue #2695.
2021-05-22 10:10:01 +02:00
Martin Kleusberg 50b48bc756 Avoid multiple error messages when deleting cell values
When multiple cells are selected pressing the Delete key tries to set
all of them to an empty string. In case of a unique constraint or
similar constraints this throws an error. This commit copies the
behaviour of the set to NULL menu action in that it aborts at the first
error to avoid multiple error messages.

See issue #2704.
2021-05-22 09:55:49 +02:00
Martin Kleusberg 8ffe641ae1 Fix d7074bb834
This fixes a bug introduced in d7074bb834.
It turns out we cannot treat the edited table as similar to the other
tables after all.
2021-05-22 09:44:00 +02:00
Juho Lee 4c40400001 Update Korean Translation file (#2624)
* Update Korean L10N Strings for translation

* Fix typo in Korean translation file

* Translate Korean Strings based on the latest master branch
2021-05-21 21:42:38 +02:00
Martin Kleusberg 7c1454e785 Fix possible crash when removing constraints from table definition
This fixes a possible crash when trying to remove a table constraint
from a table definition. The issue was introduced in commit
4e1d1ff49f.

See issue #2670.
2021-05-21 19:49:03 +02:00
Martin Kleusberg d7074bb834 Show tables in foreign key editor in alphabetical order
Make sure to list the tables in the foreign key editor of the Edit Table
dialog in alphabetical order instead sorting them randomly.

See issue #2700.
2021-05-21 16:52:55 +02:00
Martin Kleusberg d0f5ec5081 Remove obsolete code 2021-05-19 16:40:12 +02:00
Justin Clift 00dd35b0e5 Updated public user app cert and docker certs 2021-05-02 23:36:04 +10:00
Manuel f59bbf222a Merge pull request #2644 from anandsanto/master
update plotwindow's selection in tablebrowser
2021-04-27 21:28:15 +02:00
pgp 5fd2cea5da Fix typo in AboutDialog in italian translation 2021-04-24 12:05:53 +02:00
mgrojo 967780d00b Fix 'Set Encryption': don't reuse current file after closing
Otherwise db.currentFile() is empty.

See issue #2654 and discussion in #2579
2021-04-04 13:31:55 +02:00
mgrojo 2a830e5a3a Update QDarkStyleSheet to v3.0.rc and add new light style
Thanks to a new light style provided by QDarkStyleSheet in v3.0.rc
(9eea545) we can add a new light style option.

`qdarkstyle/dark/style.qrc` had to be renamed to
`qdarkstyle/dark/darkstyle.qrc` and `qdarkstyle/light/style.qrc` to
`qdarkstyle/light/lightstyle.qrc` in order to include both as resources.

See issues:
- https://github.com/ColinDuquesnoy/QDarkStyleSheet/issues/240
- https://github.com/ColinDuquesnoy/QDarkStyleSheet/issues/273
- #2558
2021-03-30 23:54:55 +02:00
mgrojo c5199f559d Table Browser: Support extended selections
Support of extended selections (non-contiguous cell selections using
Control+Click). The following changes were necessary:

- Copy to clipboard iterates over rows and columns and leaves holes for
  non-rectangular selections as empty cells (HTML) or as NULL (SQL).
  Fix: Additionally the SQL copy uses NULL when the cell has NULL, not ''.
- Shortcuts for column and row selection take into account non-contiguous
  cells and only select those columns/rows.
- The legend in the status line counts correctly non-contiguous rows or
  columns.
- Delete Record has been adjusted so only contiguous selected cells are
  removed in a single step. Fix: selecting line after removing has been
  deleted since the standard behaviour is giving better result.
- ExtendedSelection has been enabled in TableBrowser, it was already
  enabled in Execute SQL table-widget.

Possible improvements: pasting from the internal clipboard does not keep
the layout of copied non-rectangular selections.

See issues #1104 and #2638
2021-03-26 18:40:38 +01:00
Anand N a51d6c1074 update plotwindow's selection in tablebrowser
This is a feature that was already present but was
broken after 834e6508bf
2021-03-25 17:11:25 +05:30
mgrojo 93a5c2d0ca Import: don't assume an empty file is a text file
Since in any case, the empty file has nothing to import and it's admitted by
SQLite as a valid database, it's better to revert to the previous behaviour,
where an empty file dropped or opened by the file manager was treated as a DB
and indeed worked.

The behaviour was changed by cfa4dee3be

See issue #2636
2021-03-20 14:16:23 +01:00
mgrojo 78edc8f991 Table Browser: give hint of table sorted or filtered state in the toolbar
The Clear Filters button is enabled if and only if there is some filter
set for the browsed table.

The Clear Sorting button is enabled if and only if the table is sorted by
some column.

See issue #2616
2021-03-19 16:58:17 +01:00
mgrojo 580e86e2f9 Table Browser: "Clear Filters" button to clear the global filter
See issue #2616
2021-03-19 14:20:40 +01:00
mgrojo 035a541c5b Import: "Yes to All" to skip all further prompts
"Yes" to not be prompted next time for the same table, but yes for different
tables.

"Yes to All" to not be prompted again for any existent tables.

See issue #2633
2021-03-19 13:44:29 +01:00
Martin Kleusberg f69f66cc46 Add Swedish translation
Thanks to Jan-Erik!

See issue #2621.
2021-03-16 17:25:40 +01:00
Martin Kleusberg 4e1d1ff49f Store table constraints in a vector instead of a set
This should make sure we keep the constraints in the order the parser
reads them so the output of the SQL export becomes more stable.

See issue #2627.
2021-03-16 15:19:07 +01:00
Juho Lee fb80d3bcd1 Add auto completion for math functions (#2631)
* Add auto completion for math functions

Math functions are introduced from sqlite 3.35.
Refer https://www.sqlite.org/lang_mathfunc.html
FYI, it need to compile sqlite with -DSQLITE_ENABLE_MATH_FUNCTIONS

* Add auto completion for math function when it had been enabled

Math function can be used when sqlite is equal or higher than 3.35 and
compiled with SQLITE_ENABLE_MATH_FUNCTIONS. When sqlite is compiled with
SQLITE_OMIT_COMPILEOPTION_DIAGS, there is no way to check the compile
options. In this case, we'll check only the sqlite version. Otherwise,
it will check whether sqlite was built with SQLITE_ENABLE_MATH_FUNCTIONS.
2021-03-16 14:51:55 +01:00
Martin Kleusberg ccb8c9ee97 Speed up removing of comments from SQL queries
This commit replaces the regular expressions for removing end of line
and block comments from SQL queries provided by the user by a hand
written state machine. This makes the code a lot faster, especially for
longer SQL scripts with many statements and many comments in them. It is
also not harder to read than the rather complex regular expressions from
before - possibly even easier to read.

See issue #2619.
2021-03-15 19:42:11 +01:00
mgrojo a5cc259b45 Data Browser: export query results as JSON
In this case too, the corresponding menu entry for exporting the query
results to JSON was missing although it was straight forward to add it
with the same scheme as for CSV.

Renamed the CSV action for consistency.

Related to issue #2607
2021-03-12 20:51:53 +01:00
mgrojo 2826e7b989 Save as view: allow any state in the table
This check was supposed to help the user understand what this operation was for,
but it was actually preventing to save as view table states that had global
filter, display formats or custom order and not column filters. It's better to
give the user the freedom, even to create maybe useless vies as:

`CREATE VIEW "example_view" AS SELECT * FROM "main"."example"`

See issue #2615
2021-03-12 20:28:42 +01:00
Martin Kleusberg 5d80f9877d Fix running ALTER TABLE statements in Execute SQL tab
This fixes a bug introduced in 73efa11680.
Because SQLite reports ALTER TABLE statements to return one column worth
of data, DB4S assumed they are close to a SELECT statement and therefore
did not fully execute them.

See issues #2563 and #2622.
2021-03-12 19:11:52 +01:00
mgrojo e225dc1e42 Export query results as JSON
The corresponding menu entry for exporting the query results to JSON was missing
although it was straight forward to add it with the same scheme as for CSV.

Related to issue #2607
2021-03-05 23:57:34 +01:00
mgrojo 36c5b1baf4 Import: allow CSV separator and quote to be passed from command line
Support these settings from the command line:
--option importcsv/separator=\, --option importcsv/quotecharacter=\'

Since they are stored as string, they cannot convert to QChar unless
manually converted.

See issue #2589
2021-02-28 22:05:43 +01:00
Tobias Nießen 38cdd94e24 src: rename sqlb::Query::setColumNames 2021-02-28 09:19:42 +01:00
mgrojo 248a630dd1 Import: do not remove characters from CSV header fields
This is as described in RFC-4180. See issue #2445.
2021-02-26 22:09:47 +01:00
mgrojo cfa4dee3be Import: support importing the single file argument as a CSV file
This will allow associating DB4S to CSV files and dropping a CSV file to be
importing into a new in-memory database, when there is no DB open yet.

See issue #2589
2021-02-21 15:12:02 +01:00
mgrojo 09aaaccace Import: Add import-csv option to command line to import CSV files
The argument can be passed several times and all the CSV files are added to
the Import CSV dialog. When no database to open is passed in the command line,
the CSV files are imported into a new in-memory database, which could later
be saved as a file, if desired.

This option could be used as basis for adding a file association to CSV files
for DB4S.

See issue #2589.
2021-02-20 19:07:52 +01:00
mgrojo 3ad352467c Better formatting of the help messages so they are easier to translate
- Command line arguments are not given to translations, only descriptions
  and placeholders.
- Formatting is done programmatically, so developers and translators don't
  have to adjust that themselves.

This will affect translations but will be better in the long run.
2021-02-20 16:10:00 +01:00
Martin Kleusberg 1c0cf443b5 Fix editing of tables without rowid
This fixes some severe bugs in the Browse Data tab with editing and
deleting rows in WITHOUT ROWID tables.

These were introduced in 02db68107a.

See issue #2582.
2021-02-08 18:45:00 +01:00
Martin Kleusberg 73efa11680 Speed up executing SQL statements in the Execute SQL tab
This improves the performance of executing multiple modifying SQL
statements, like INSERTs or UPDATEs, in the Execute SQL tab a lot by
not updating the plot dock after every single statement.

See issue #2572.
2021-02-03 19:16:50 +01:00
Martin Kleusberg 070bfd38cf Add extra border to make frozen table columns more obvious
This adds an extra border between frozen and ordinary table columns in
the Browse Data tab.

See issue #1888.
2021-01-31 20:33:27 +01:00
Martin Kleusberg 02db68107a Refactor the way we store a database schema
This commit does a lot of refactoring. But most noticeably it changes
two things:

1) Instead of saving all objects (tables, views, indices, triggers) of a
   schema in a common map, we now store tables/views, indices and
   triggers in three separate maps. This has a number of benefits:
   - It resembles more closely how SQLite stores its data internally and
     therefore achieves greater compatability e.g. for databases with a
     view and a trigger with the same name.
   - It reduces the need for runtime polymorphism. This makes the code
     run a bit faster.
   - By working with explicit types more often more error checking can
     be done at compile time, making the code less error prone.
   - The code becomes a lot clearer to read.

2) By making View inherit form Table, views are now a sort of tables.
   This has the following benefits:
   - This is a again how SQLite stores views internally which again
     should increase compatibility a bit.
   - We mostly treat views and tables the same anyway and with these
     changes we can unify the code for them even more.
2021-01-30 20:47:31 +01:00
Martin Kleusberg 13ab455d5c Unify handling of views and tables in SqliteTableModel a bit
This also avoids querying the column names another time when browsing a
view.
2021-01-28 22:42:39 +01:00
Martin Kleusberg 18c7e9c477 Change WHERE clauses of queries to use column names instead of indexes
For the same reasons we changed the ORDER BY part of query objects to
use their names instead of their indexes to address columns, this commit
changes the handling of the WHERE part of a query to use column names
too.
2021-01-28 20:06:49 +01:00
Martin Kleusberg 94023a55e8 For sorted column remember column name instead of column index
This changes the structures for representing SELECT statements to save
the names of sorted column instead of their indexes. This change has
several benefits:
- It prepares the Query class to store actual real-world SELECT
  statements in the future.
- It prepares us to sort by expressions instead of just columns.
- This way we do not need an extra list of column names to generate the
  ORDER BY part of the SELECT statement when building it.
2021-01-28 20:05:46 +01:00
Martin Kleusberg f6ebc74131 Fix e54664dd03
Fix an error introduced in e54664dd03.
2021-01-26 19:21:22 +01:00
Martin Kleusberg a6d48f1ae4 Simplify interface and implementation of SqliteTableModel
This simplifies the usage and the implementation of the SqliteTableModel
a bit by making the two operating modes it supports (manual query and
interactive query) more obvious in its public interface as well as
simplifying the control flow in the private implementation.
2021-01-25 18:13:49 +01:00
Martin Kleusberg e54664dd03 Change some function parameters with negated name
Change some function parameters which are named like "dont..." to make a
positive statement. This should hopefully avoid some confisions with
double negation.
2021-01-24 10:20:50 +01:00
vlakoff 06200bfb44 Some fixes to the French translation 2021-01-23 12:25:45 +01:00
mgrojo c8cd858699 Add "Save Database As..." action
The feature is implemented using the SQLite backup API.

https://sqlite.org/backup.html

This allows saving in-memory databases and saving database files to another
file name.
2021-01-22 23:54:26 +01:00
Martin Kleusberg 42ce8995c8 Fix build for Qt versions older than 5.10 2021-01-22 16:47:00 +01:00
Martin Kleusberg 7382ed882b Fix build on Qt 5.5 2021-01-22 15:35:51 +01:00
Martin Kleusberg b3d30cad4b Enable buttons for editing/deleting tables and similar on first click
When opening a database and clicking on a table in the Database
Structure tab, the buttons for modifying or deleting the table were
still disabled. Only on the second click activated the buttons
correctly.

See issue #2528.
2021-01-22 14:56:26 +01:00