Commit Graph

615 Commits

Author SHA1 Message Date
Guy Sartorelli 4e53c35b53 MNT Deprecate unusable property
This property must always have the value 'AND' or an exception will be
thrown - it should be deprecated. Also, no need to process the query
before throwing.
2022-06-30 15:53:17 +12:00
Steve Boyd 3a0fff25de FIX PDO in PHP 8 2022-06-30 12:34:05 +12:00
Steve Boyd a77ca74a7e FIX Ensure not passing null to mysql methods for PHP 8.1 compatibility 2022-06-29 09:34:30 +12:00
Steve Boyd c80e10f892
FIX PDO transaction in PHP 8, add GitHub Actions CI (#10360) 2022-06-27 15:30:03 +12:00
Guy Sartorelli 8ae7f30c41 Merge branch '4.11' into 4 2022-05-27 15:19:51 +12:00
Guy Sartorelli dec85819bd Merge branch '4.10' into 4.11 2022-05-27 15:19:39 +12:00
Guy Sartorelli 0bc3ed4d2c Merge branch '4.9' into 4.10 2022-05-27 15:19:17 +12:00
Sabina Talipova cb37869bac
Merge pull request #10297 from creative-commoners/pulls/4/gridfield-set-polymorphic-class
Issue was fixed
2022-05-13 14:01:17 +12:00
Mojmir Fendek 26d59944e0 ENH: RemoveAll() memory performance enhancement. 2022-05-13 11:19:04 +12:00
Guy Sartorelli 19bb72e7c7 FIX Correctly remove relations with ManyManyThroughList::removeall
Instead of just setting one side of the relation to null in the through
list, remove the rows entirely.
Remove only the relations which match the filters that have already been
set on the list.
This is consistent with the way ManyManyList works.

Also some small tidy-up (removing an unnecessary line break and an
unused "use" statement)
2022-05-05 11:21:51 +12:00
Guy Sartorelli 2836478c72 API Add method to get foreign class key on polymorphic has_many 2022-05-02 18:29:01 +12:00
Steve Boyd 337c6e583c ENH Various fixes for PHP 8.1 compatibility 2022-04-27 09:29:40 +12:00
Steve Boyd 511b3bb060 ENH PHP 8.1 compatibility 2022-04-14 13:12:59 +12:00
Steve Boyd f1678781a2 ENH Various fixes for PHP 8.1 compatibility 2022-04-11 17:22:22 +12:00
Steve Boyd 814c5b2fd0 ENH Fix deprecation issues for PHP 8.1 compatibility 2022-04-06 11:34:34 +12:00
Steve Boyd 0318372641 API Implement updated Serializable API 2022-02-14 13:26:11 +13:00
Tyler Trout 6b1c5eb6d7
NEW Allow methods to be used for flexible searchable_fields (#10199)
* Allow methods to be used for flexible searchable_fields

* match_any key

* Documentation

* Update docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md

Co-authored-by: GuySartorelli <36352093+GuySartorelli@users.noreply.github.com>

* Search fields test

* Newlines

* Update src/ORM/Search/SearchContext.php

Co-authored-by: Steve Boyd <emteknetnz@gmail.com>

* Update docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md

Co-authored-by: Steve Boyd <emteknetnz@gmail.com>

* Removed comments and whitespace. Linting fixes

Co-authored-by: GuySartorelli <36352093+GuySartorelli@users.noreply.github.com>
Co-authored-by: Steve Boyd <emteknetnz@gmail.com>
2022-02-10 09:40:16 +13:00
Mojmir Fendek 89c87ddbf8
NEW: Static validation for relationships. (#9874)
* NEW: Static validation for relationships.

* Unit tests added.

* PR fixes

* PR feedback: Execute validation on flush.

* PR fixes.

* PR fixes.
2022-02-04 14:41:09 +13:00
Ingo Schommer d8499a24d0
NEW NullDatabase (#10016)
* NEW DatabaselessKernel to support operation without DB

This is required for GraphQL code generation in CI (without a working runtime database/webserver environment).
Context: https://github.com/silverstripe/silverstripe-graphql/issues/388

* New --no-database option for sake

* Refactor to abstract class

* Apply feedback peer review

Co-authored-by: Aaron Carlino <unclecheese@leftandmain.com>
Co-authored-by: Maxime Rainville <maxime@silverstripe.com>
2022-02-04 10:07:27 +13:00
LiamKearn ce3e07a189
DOC DBComposite reword to make a little more sense. (#10193)
* Docs: DBComposite reword to make a little more sense.
* Update src/ORM/FieldType/DBComposite.php
Docs: Rewording DBComposite explanation based on feedback
Co-authored-by: Steve Boyd <emteknetnz@gmail.com>
2022-01-18 15:52:01 +13:00
Mojmir Fendek 3db1435df7
NEW: Allow DateTime to be immutable (#10125)
* BUG: Datetime modify() returns a new field instance.
* PR fixes.
* PR fixes.
2022-01-18 09:41:11 +13:00
Nicolaas / Sunn Side Up d1cac485b7
ENH Speed up DataObject::get_by_id by checking if there is an ID at all 2022-01-17 09:45:56 +13:00
Michal Kleiner dee0b1faf4
Merge pull request #10020 from GuySartorelli/patch-4
FIX Remove limits in removeAll method
2022-01-15 10:42:19 +13:00
Michal Kleiner 645e1f14bd
Merge pull request #10173 from GuySartorelli/patch-2
FIX Allow custom SELECT to be used for sorting in DataQuery::column()
2021-12-14 10:23:48 +13:00
GuySartorelli 0b0c13764b FIX allow custom SELECT to be used for sorting in DataQuery::column().
If a custom select clause (using special features such as `CASE`) is used, and it was added using `SQLSelect::selectField`, the custom select clause should be retained when calling DataQuery::column().
2021-12-14 08:01:02 +13:00
Lukas 552cf5944d
MNT Fix various typos with codespell (#10177) 2021-12-13 21:05:33 +13:00
Maxime Rainville 27d7c2fe85
Merge pull request #9749 from gurucomkz/patch-9453-mysql8-ints
FIX Don't use int width for mysql >= 8.0.17 #9453
2021-12-13 12:39:12 +13:00
Thomas Portelange 97ab957de8
ENH Use ::create to get DropdownField instance in DBEnum (#10175)
This allows using alternate dropdown implementation.
2021-12-11 20:12:07 +13:00
Sergey Shevchenko 9e2d661689 FIX: Make MySQLSchemaManager::shouldUseIntegerWidth() private 2021-12-08 11:19:47 +13:00
Sergey Shevchenko e68e65badc feat: added config value to force certain behaviour & added a note to the docs 2021-12-08 11:18:00 +13:00
Sergey Shevchenko 2c9ba8bc45 fix: conform with linter 2021-12-08 11:18:00 +13:00
Sergey Shevchenko 62725a5db3 fix: added exception for MariaDB 2021-12-08 11:18:00 +13:00
Sergey Shevchenko 5e26757a9e
Merge branch 'silverstripe:4' into 4 2021-11-15 22:07:11 +13:00
Loz Calver 20134e6a4f
NEW Add FirstPage() and LastPage() to PaginatedList (#10129) 2021-11-08 09:26:21 +13:00
Sergey Shevchenko 04b7ad51b8
Merge branch 'silverstripe:4' into 4 2021-11-01 13:12:59 +13:00
GuySartorelli 059d8aac0a
NEW Add afterUpdateCMSFields method to DataObject. (#9819) 2021-10-26 16:05:11 +13:00
Mo Alsharaf 2c1ef4df23
MNT Update URL in docs for ICU documentation (#10118) 2021-10-15 11:28:16 +13:00
Michal Kleiner 38fe326262 MNT Fix minor typos 2021-09-25 00:23:43 +12:00
Michal Kleiner 1e5414eac7 FIX Use correct ancestor class when querying for stage and live children
The right ancestor class that has the Hierarchy extension applied needs to be used
since it doesn’t have to be the class directly extending from DataObject, which means
the ID and ParentID columns might be in different tables.
2021-09-25 00:23:43 +12:00
Matt Peel f99ba5d716 NEW Add extension point to DataObject->hydrate() 2021-08-25 16:07:02 +12:00
GuySartorelli cacd762357
Avoid "new" keyword to instantiate CompositeValidator
The CompositeValidator is Injectable, so we should allow project code to replace it here via the Injector.
2021-08-02 12:46:53 +12:00
GuySartorelli 5699db306d
FIX: Remove limits in removeAll method.
Keeping a limit here results in a DatabaseException "This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'"
2021-07-12 17:14:46 +12:00
Steve Boyd f6e8d6e591 Merge branch '4.8' into 4 2021-07-07 14:03:02 +12:00
Steve Boyd 87d076faa6 FIX Cast DBInt value to int 2021-07-06 16:43:54 +12:00
Steve Boyd 8e803bbcfc FIX Parse Enums with dots in their values 2021-07-01 16:00:08 +12:00
Steve Boyd 9463aaf571 Merge branch '4.8' into 4 2021-06-08 11:49:01 +12:00
David Peck 28b5b803be FIX Defensively copy mocked datetime 2021-06-05 16:46:19 +12:00
Michal Kleiner 2017a20433 FIX Use empty array as a fallback for preg_split within dbtext summary
If the content is invalid for whatever reason e.g. when instantiating
a DBText field to get a summary of text through
`DBField::create_field('Text', $content)->Summary(10)`, preg_split returns
false and the rest of the code expects an array.
This tweak ensures an array is always returned even when preg_split fails.
2021-06-02 15:17:58 +12:00
Steve Boyd a3df66860f Merge branch '4.8' into 4 2021-05-31 17:05:11 +12:00
Steve Boyd 9ccdb8efb2 Merge branch '4.7' into 4.8 2021-05-31 17:04:54 +12:00
Maxime Rainville 472fc4ebb4
BUG Update DataQuery::exists to return false when limit causes no result to be returned (#9946)
* BUG Update DataQuery::exists to return false when limit causes no result to be returned

* Update comment

* Fixing linting issue
2021-05-31 16:50:58 +12:00
Sam Minnee c7c6bdebdf FIX: Allow join-object to be referenced as a component
This avoids having arbitrary differences between a join object and a
has-one relation.
2021-05-20 20:32:25 +12:00
Maxime Rainville 6fc25e4e96
RFC Add chunk method to DataList to iterate over large dataset (#8940) 2021-04-14 07:49:44 +12:00
Nicolaas 2ecd8b34ee
adding use SilverStripe\Security\Member; to make sure linting works
adding `use SilverStripe\Security\Member;` to make sure that linting works.
2021-04-01 23:36:36 +13:00
Nicolaas 504e20320e
Update DBBoolean.php (#9893) 2021-03-24 12:05:33 +13:00
Joe Harvey 33365b92f3 Bug Fix - Ensure DataQuery::exists() SQL is both valid MySQL and T-SQL
The original SQL statement is not valid T-SQL for use with SQL Server
2021-02-08 17:22:20 +00:00
Maxime Rainville 9ca33950a2
API Add a CREATE_MEMORY_HYDRATED option to DataObject constructor (#9767) 2021-01-21 14:07:06 +13:00
3Dgoo d1cca0f3fb
Fix DataQuery::exists() not working correctly
Fixes `DataQuery::exists()` not working correctly in some cases as discussed in #9809
2021-01-20 17:03:36 -08:00
Steve Boyd ed5c1488c8
Merge pull request #9817 from creative-commoners/pulls/4/fix-dbcomposite-indexspecs
FIX DBComposite getIndexSpecs method
2021-01-17 11:18:35 +13:00
Ingo Schommer 6153f441ee Merge branch 'phpdoc-fixes' into 4 2021-01-14 11:08:22 +13:00
Serge Latyntcev 2f64667bd6 FIX DBComposite getIndexSpecs method using self API to get the list of db fields 2021-01-07 16:19:54 +13:00
3Dgoo 3b74c2596f
Fix DataQuery::exists() not working correctly
Fixes `DataQuery::exists()` not working correctly in some cases as discussed in #9809
2020-12-29 16:45:58 +10:30
William Desportes c932d7e7fb
Fix the phpdoc blocks 2020-12-21 22:23:23 +01:00
Steve Boyd 5be045f9a2 FIX Bug when specifying 0 in ArrayList::offsetSet 2020-12-15 14:50:10 +13:00
Steve Boyd af933e8226 MNT Double quote yaml string, fix phpcs warnings 2020-11-30 11:37:35 +13:00
Guy Marriott b0762593da
Merge branch '4.6' into 4.7 2020-11-17 15:46:54 -08:00
Damian Mooyman 5d45bbdd0d
Update src/ORM/DatabaseAdmin.php
Co-authored-by: Guy Marriott <guy.the.person@gmail.com>
2020-11-13 11:48:50 +13:00
Damian Mooyman 2753516783
Fail over if calling deprecated method 2020-11-13 08:27:53 +13:00
Damian Mooyman 405a1f7cb6
ENHANCEMENT Better optimised class name migration with substantially fewer queries
Fixes #9752
2020-11-12 16:10:28 +13:00
Sergey Shevchenko 51402a9c42
fix: don't use int width for mysql > 8.0.17 #9453 2020-10-29 10:54:52 +13:00
Steve Boyd 6e77d5eada NEW DataObject related objects service 2020-10-29 09:29:26 +13:00
Bernard Hamlin f00f64120d
NEW Allow setting sql_mode via config (#9721) 2020-10-22 15:01:30 +13:00
Robbie Averill 4d54a2110f Update spaces in syntax, single quotes, early returns where possible 2020-10-01 17:36:14 -07:00
Robbie Averill ae1e17edec Update exception assertions in tests and remove deprecated annotations 2020-09-25 10:06:49 -07:00
Robbie Averill 27bd5d12e3 ENH Replace E_USER_ERROR errors with exceptions 2020-09-24 23:51:21 -07:00
Dan Hensby ae0ece2b02
Merge pull request #9665 from creative-commoners/pulls/4/php8-fqcn-token 2020-09-18 20:44:22 +01:00
Sam Minnee 0d7c5a9ece NEW Add/remove callbacks on RelationList
This provides a mechanism for adjusting the behaviour of these
relations when building more complex data models.

For example the following example has a status field incorporates a
Status field into the relationship:

```php
function MyRelation() {
  $rel = $this->getManyManyComponents(‘MyRelation’);
  $rel = $rel->filter(‘Status’, ‘Active’);

  $rel->addCallbacks()->add(function ($relation, $item, $extra) {
    $item->Status = ‘Active’;
    $item->write();
  });
}
```

Introduces a new library dependency: http://github.com/sminnee/callbacklist
2020-09-18 13:33:42 +12:00
Steve Boyd 015ea8cfc8 Merge branch '4.6' into 4 2020-09-11 11:54:23 +12:00
Robbie Averill de61681dec
Merge pull request #9634 from open-sausages/pulls/4/ellipsis
BUG Use proper ellipsis character in the various summary method.
2020-09-10 14:48:33 -07:00
Maxime Rainville acdebcdba7 Fix unit test 2020-09-10 17:08:13 +12:00
Steve Boyd 02827a6670 FIX Problem with direct compare in SELECT statement causing incompatibility with SQL Server database
Co-authored-by: Tomas Bilek
2020-09-10 14:48:09 +12:00
Steve Boyd 4c3a5441b2 Merge branch '4.6' into 4 2020-09-09 13:58:35 +12:00
Sam Minnee e0f3797489 FIX: Remove deprecated & non-functional default argument config
This throws deprecation errors on PHP 8.

Fixes #9666
2020-09-07 17:24:00 +12:00
Guy Marriott ff04f97149
Add return type
Co-authored-by: Robbie Averill <robbie@averill.co.nz>
2020-09-01 08:43:36 -07:00
Guy Marriott 3575070b9d FIX Removing selected column detail only if having is empty (MySQL "feature") 2020-09-01 16:21:43 +12:00
Guy Marriott f9fc4f6641 FIX Allow for BC for DB adapters that return an actual boolean when selecting boolean literals in SQL 2020-09-01 16:20:07 +12:00
Guy Marriott ef0af7ae9c FIX Exists statements can't remove GROUP BY if there's a HAVING clause as it might rely on an aggregate 2020-09-01 16:20:07 +12:00
Guy Marriott 91591373d6 NEW Add exists as a method to the DataQuery API that will generate an SQL "exists" query
The exists query in SQL allows the query optimiser (engine specific) to execute these queries much faster - often only needing the presence of an index to return "yes it exists".
2020-09-01 16:20:07 +12:00
Mason Dechaineux abd0f3fbf3 Fix DataList->column mutating underlying DataQuery 2020-08-21 09:25:27 +10:00
Sam Minnée b810b7d5c9
API: Allow for user-created objects to have values passed in the constructor (#8591) 2020-08-20 12:28:31 +12:00
Maxime Rainville 26b8b7964e Rename DefaultEllipsis to defaultEllipsis 2020-08-07 09:48:42 +12:00
Maxime Rainville 896c0e4388 BUG Use proper ellipsis character in the various summary method. 2020-08-06 19:37:03 +12:00
Mojmir Fendek c2ed6a4cd6 NEW: WithMockTime callback. 2020-08-06 11:18:39 +12:00
Nicolaas d292eb8840
PATCH: fix doctype return type hints: add null 2020-07-23 21:10:17 +12:00
Robbie Averill 84b4057a9a
Merge pull request #9406 from chrispenny/feature/standardise-get-cms-validator
v4 improvement: Standardise getCMSValidator for DataObjects/Forms
2020-07-16 15:58:33 -07:00
Garion Herman d408a4e714 Merge branch '4.6' into 4 2020-07-13 12:28:14 +12:00
Garion Herman fbe0f5a981 Merge branch '4.5' into 4.6 2020-07-13 12:27:02 +12:00
Ingo Schommer 8d6a248431 Merge remote-tracking branch 'origin/4.6' into 4 2020-07-11 09:07:39 +12:00
Maxime Rainville b780c4f504 BUG Tweak DBHTMLText::Plain to avoid treating some chinese characters as line breaks. 2020-07-09 13:33:43 +12:00
Sam Minnee 01d3b4fd96 FIX: Set many-many-through joinRecord on newly added records.
When many-many-through relations are queried, a joinRecord is set on
each DataObject in the list to provide the extra fields defined on
the connector object. This didn’t previously happen when the record
was first add()ed to a list. This fixes that bug.
2020-07-02 15:18:12 +12:00