Releases: Screenfeed/autowpdb
Releases · Screenfeed/autowpdb
0.3
Tests
Unit and integration tests have been added, they cover 100% of the current code.
Sadly, we're stuck with PHPUNIT 7.5.20 because of WP’s test suite 😢.
AbstractCRUD
prepare_select_for_query()
:- Trim quotes.
- Add backticks.
- Remove empty fields.
- Don't use
esc_sql()
anymore.
get_placeholders()
:- Return only valid columns.
cast()
:- When the placeholder is not
%d
nor%f
and the column is not serializable, return numeric values as string.
- When the placeholder is not
Basic
get()
:- Disallowed
ARRAY_N
value for the output type, as it conflicts withcast_row()
.
- Disallowed
AbstractTableDefinition
- An instance of
Worker
can be injected into the constructor.
DBUtilities / DBWorker\Worker
- The static class
DBUtilities
is now the instanciable classDBWorker\Worker
that implementsDBWorker\WorkerInterface
.
Seeing howDBUtilities
was used at this point, using a static class was not shorter. The advantage now is that the instance can be typehinted against the interface. Although, it is not typehinted directly inAbstractTableDefinition
today, we need php 7.1 for nullable typehints (this is for a future release), butinstanceof
is used for the time being.
The full instanciation is nownew Table( new MyTableDefinition( new MyWorker() ) )
.
AbstractTableDefinition
falls back tonew DBWorker\Worker()
if no custom worker is specified as argument. - Hide database errors in most methods.
table_exists()
:- Fix returned value by comparing the query value to the unescaped name of the table.
- New method
get_last_error()
, which returns the last$wpdb
error. sanitize_table_name()
:- Allow
0
as a valid table name.
- Allow
quote_string()
:- Do not escape simple quotes anymore, it is done by
esc_sql()
inprepare_values_list()
.
- Do not escape simple quotes anymore, it is done by
can_log()
:- New filter
screenfeed_autowpdb_can_log
.
- New filter
Table
- New method
get_last_error()
, which returns the last DB error. clone_to()
:- Allow
0
as a valid table name.
- Allow
TableUpgrader
- Use
static
instead ofself
, so the class can be extended and tested. init()
:- Move tests from the constructor to the
init()
method. - Don't add the upgrade hook if the hook name is set to
false
.
- Move tests from the constructor to the
table_is_up_to_date()
:- Fix when downgrade is handled, it was returning the opposite of the expected value.
0.2
Main changes:
-
DBUtilities
:- Improved methods a bit, like wrapping table names into quotes in the queries.
- New methods:
delete_table()
,reinit_table()
,empty_table()
,clone_table()
,copy_table()
,count_table_rows()
, andsanitize_table_name()
. This is inspired by what BerlinDB does.
-
New class
Table
: this class basically combinesTableDefinitionInterface
andDBUtilities
, to be easier to work with. -
CRUD
classes:- Renamed
get_table()
intoget_table_definition()
to prevent confusion between the classesTable
and the interfaceTableDefinitionInterface
. AbstractCRUD
: the propertytable_definition
is now private. Useget_table_definition()
in sub-classes instead.
- Renamed
-
AbstractTableDefinition
:get_table_name()
now usesDBUtilities::sanitize_table_name()
.- New method
jsonSerialize()
(from the interfaceJsonSerializable
): returns an array containing the method results. The array keys aretable_version
,table_short_name
,table_name
,table_is_global
,primary_key
,column_placeholders
,column_defaults
, andtable_schema
.json_encode()
can be used directly on the class instance now. - New magic method
__toString()
: this will simplyjson_encode()
the class.
-
TableUpgrader
:- Signature change: a
Table
object must be used as first argument instead ofTableDefinitionInterface
. - New methods
table_is_allowed_to_upgrade()
anddelete_table()
. - The table version is not deleted from the DB anymore if the table upgrade failed.
- Signature change: a
0.1
Initial release.