Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NextrasDataSource faulty checks #984

Closed
mskocik opened this issue Aug 25, 2021 · 6 comments
Closed

NextrasDataSource faulty checks #984

mskocik opened this issue Aug 25, 2021 · 6 comments

Comments

@mskocik
Copy link

mskocik commented Aug 25, 2021

Although NextrasDatasource accepts ICollection in constructor, comparisons for Nextras\Orm v4 added in #920 and #937 take into account only DbalCollection.

One would expect ICollection implementations usable.

@radimvaculik
Copy link
Member

The best option is drop support for v3.1, leave v4 only and refactor it to ICollection everywhere. Current state is not perfect at all, but it's good compromise between backward compatibility with v3.1 and v4.

@f3l1x
Copy link
Member

f3l1x commented Jan 24, 2023

I am in. Let's support only v4.

@mskocik
Copy link
Author

mskocik commented Jan 24, 2023

My point wasn't about v3/v4 difference, but inpropriate collection type enforcement.

This can happen when you use Nextras\Orm\Repository->findByIds(). Although DbalCollection is usually returned, there are cases when ArrayCollection is returned instead.

if (!$this->dataSource instanceof $this->dbalCollectionClass) {
throw new UnexpectedValueException(
sprintf(
'Expeting %s, got %s',
$this->dbalCollectionClass,
get_class($this->dataSource)
)
);
}

$order = $this->dataSource->getQueryBuilder()->getClause('order');
if (ArraysHelper::testEmpty($order)) {
$this->dataSource = $this->dataSource->orderBy(
$this->prepareColumn($this->primaryKey)
);
}

The code above could be changed that the second snippet (DbalCollection ordering) is executed only on DballCollection instance:

if ($this->dataSource instanceof $this->dbalCollectionClass) { 
    $order = $this->dataSource->getQueryBuilder()->getClause('order');   

    if (ArraysHelper::testEmpty($order)) { 
 	$this->dataSource = $this->dataSource->orderBy( 
 		$this->prepareColumn($this->primaryKey) 
 	);
     } 
}

@radimvaculik
Copy link
Member

@mskocik See #1062. All good?

@mskocik
Copy link
Author

mskocik commented Jan 24, 2023

@radimvaculik Should be fine according to changes in PR. Haven't tested it yet on real code.

@radimvaculik
Copy link
Member

radimvaculik commented Apr 20, 2023

@mskocik Have you tested? Should we close this issue?

RYUcze pushed a commit to RYUcze/datagrid that referenced this issue Jul 10, 2023
MrVoltz pushed a commit to JIHO-Innovations/datagrid that referenced this issue Feb 2, 2024
paveljanda added a commit that referenced this issue Mar 13, 2024
* PHP 8.0

* Translator: switch from ITranslator to Translator (#973)

* [7.x] Bootstrap 5 + PHP 8 + vanilla javascript (#1021)

* Bootstrap 5

* Bootstrap 5 (docs)

* Bootstrap 5

* form-control -> form-select

* Bump bootstrap-select for Bootstrap 5 support

* Removed `input-sm` from Bootstrap 3

See https://getbootstrap.com/docs/4.0/migration/#forms-1

* Bootstrap 5: When selectpicker, replace form-select classes with form-control and refresh it

* Hide `underline` also for `dropdown-item`. And merged into one CSS rule.

* Update the filterMultiSelect initialization

* Text-align: left -> start

Co-authored-by: Radim Vaculík <radim.vaculik@gmail.com>
Co-authored-by: Jaroslav Líbal <jaroslav.libal@neatous.cz>

* [7.x] phpstan-deprecation-rules (#1061)

* Fix sort

* Add method for setting custom Action href, v6.x (#853)

* [7.x] Nextras ORM 4 support, closes #984

* Fix ElasticsearchDataSource.php data source (#1041)

* Error: Typed property Ublaboo\DataGrid\InlineEdit\InlineEdit::$itemID must not be accessed before initialization

* composer: allow-plugins: php-http/discovery

* ItemDetailForm: $httpPost: Typed property must not be accessed...

* phpstan: revert  --memory-limit=4G

* NetteDatabaseSelectionHelper: Context -> Explorer, getSupplementalDriver -> getDriver

* Update README.md

* Templates: fix variables

* data-bs-toggle attribute for multiaction button (#1072)

* dependabot.yml (#1078)

* Allow nette/utils:4.0 (#1077)

* Add onColumnShow and onColumnHide event methods (#1076)

* Add onColumnShow and onColumnHide event methods

* Add native type array

* Removed duplicity

* Return value of BackedEnum when reading Doctrine entity property. (#1081)

* Return value of BackedEnum when reading array value (#1083)

* Added method to check if filter is on default values; Closes #1082 (#1084)

* ublaboo -> contributte (#1067) (#1075)

* Delete dependabot.yml

* Gitignore: remove compat.php

* Assets: rewrite to TS and plugin system

* Add missing phpdoc type (#1090)

* Add support for `nette/utils` version `4.0.0` (#1086)

* Add missing phpdoc type

---------

Co-authored-by: Dominik Harmim <harmim6@gmail.com>

* fix: resolution name for datagrid -> attribute instead of class

* Fix timeout utils.ts (#1091)

During the build 
[tsl] ERROR in /node_modules/ublaboo-datagrid/assets/utils.ts(130,3)
      TS2322: Type 'Timeout' is not assignable to type 'number'.

* Typo fixes in docs (#1088)

* Fixed typos in columns.md

* Fixed typos in actions.md

* Update data-source.md

* Fixed typos in export.md

* Fixed typos, missing/redundant words in filters.md

* Update columns.md

* Fixed typos group-action.md

* Fixed typo inline-edit.md

* Fixed missin comma localization.md

* Fixed typos row.md

* Add support for `nette/utils` version `4.0.0` (#1086)

* Update .docs/export.md

Co-authored-by: Radim Vaculík <radim.vaculik@gmail.com>

---------

Co-authored-by: Dominik Harmim <harmim6@gmail.com>
Co-authored-by: Radim Vaculík <radim.vaculik@gmail.com>

* Housekeep: Fix cs & phpstan issues (#1097)

* Fix: Github Actions: Coverage (#1098)

* Using data-datagrid-name="<name>" instead if data-datagrid-<name>

* Fixed CSS: change .datagrid selector to [data-datagrid-name]

* Fixed inline edit plugin

* phpstan fix

* Minor CSS changes for the next verison of datagrid

* Fix cs & phpstan

* Fix failing tests

* PHP 8.1 is new minimal version

* Fix phpstan

---------

Co-authored-by: Radim Vaculík <radim.vaculik@gmail.com>
Co-authored-by: Jaroslav Líbal <jaroslav.libal@neatous.cz>
Co-authored-by: Pavel Linhart <pavel.linhart@gmail.com>
Co-authored-by: Jan Bednář <honzaxp01@gmail.com>
Co-authored-by: emololftw <60448217+emololftw@users.noreply.github.com>
Co-authored-by: Vojtěch Kaizr <wojtishek@users.noreply.github.com>
Co-authored-by: jiriermis <46221089+jiriermis@users.noreply.github.com>
Co-authored-by: Martin Procházka <juniwalk@outlook.cz>
Co-authored-by: Mia Vališová (Liliana) <118116415+lilianalillyy@users.noreply.github.com>
Co-authored-by: Vít Kutný <vit@kutny.cz>
Co-authored-by: Dominik Harmim <harmim6@gmail.com>
Co-authored-by: Tomáš Mîčka <tomas.micka@logmanager.com>
Co-authored-by: Martin Kokeš <info@martinkokes.cz>
Co-authored-by: RYUcze <125459293+RYUcze@users.noreply.github.com>
Co-authored-by: Pavel Janda <me@paveljanda.com>
Co-authored-by: Kryštof Záhumenský <zahumensky.krystof@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants