Commit Graph

12 Commits

Author SHA1 Message Date
Maxime Rainville
40b9e876ba
Merge pull request #51 from NightJar/tighten-transactions
FIX Tighten transactions
2018-10-19 10:47:46 +13:00
NightjarNZ
5eacbe7842 FIX convert index definitions to reflect actual support
It is not uncommon for an index to be defined as e.g. 'fulltext'
which SQLite3 does not support without a module to create a
virtual table (rather than an index on an existing one). The code
already in place sees that definitions be updated to 'index' on
the fly during creation and later inspection (indexList) - which
causes issue when comparing existing table definitions to what
SilverStripe expects by DataObject configuration. This discrepency
leads to tables constantly being marked to update, although
effectively nothing actually changes. We can save these CPU cycles
and a bit of head scratching by converting to a supported index type.
2018-10-16 21:57:51 +13:00
NightjarNZ
0efd40e5c2 FIX correct handwritten logic for transactions to use new API instead
Code in the field alteration logic had a queries defiend as strings to
begin and commit transactions involve with changing table or column names.
This was causing fatal errors as BEGIN is not a valid keyword within
a trasaction (see SQLite documentation excerpt below).

A new api has been introduced to deal with transactions programmatically,
and this module was updated to support this a few months ago. This is a
tidy up of some missed portions - consuming this API which correctly uses
SAVEPOINT when a nested transaction is required automatically.

https://www.sqlite.org/lang_transaction.html
Transactions created using BEGIN...COMMIT do not nest. For nested
transactions, use the SAVEPOINT and RELEASE commands.
2018-10-09 22:22:53 +13:00
NightjarNZ
418c1178a1 FIX preserve enum values with correct escaping
Enum values are themselves enumerated in sqlite as they are not supported
as a type. This leads to values being stored in their own table, and a
regular TEXT field being used in a MySQL ENUM's stead. The default value
for this field was being escaped with custom string replacement, and
erroneously relacing the backslash (a redundant operation). This lead
to invalid Fully Qualified Class Names in SilverStripe 4, which is a
required trait for polymorphic relationships. As a result any polymorphic
relationship not set on first write would then proceed to cause an execution
error the next time the dataobject with the relationship was fetched from
the database. By using the PHP supplied escape function for SQLite3 we can
avoid this, and restore functionality.

Relevant section of SQLite documentation to justify the removal of escaping
various characters, such as the backslash:

A string constant is formed by enclosing the string in single quotes (').
A single quote within the string can be encoded by putting two single quotes
in a row - as in Pascal. C-style escapes using the backslash character are
not supported because they are not standard SQL.

https://www.sqlite.org/lang_expr.html
2018-10-08 23:09:24 +13:00
Damian Mooyman
24cf40beaf
Update config / code styles for 4.0
Related https://github.com/silverstripe/silverstripe-framework/issues/7590
2017-11-23 14:11:10 +13:00
Daniel Hensby
536ada309e
Update module to work with new stricter index definitions 2017-10-10 13:09:06 +01:00
Damian Mooyman
6d74fc05cf
BUG Fix errors when 'path' isn't declared explicitly 2016-09-30 15:45:13 +13:00
Damian Mooyman
1cb63311d8
Upgrade for silverstripe namespaces 2016-09-08 15:41:17 +12:00
Damian Mooyman
e36e74ab2f API Apply SilverStripe\SQLite namespace to module 2016-06-29 13:55:45 +12:00
helpfulrobot
b2d40ed61e Converted to PSR-2 2015-12-18 07:11:01 +13:00
ClayLennart
f9153ab6c2 Add bigint support 2014-07-15 09:50:51 +02:00
Damian Mooyman
b3b82810a0 API Upgraded module to use new database ORM
API Use SQLite3::version to directly get connection version
2014-07-11 09:06:33 +12:00