Replace hardcoded database queries with dynamic queries

Created on 19 September 2024, 3 months ago
Updated 21 September 2024, 3 months ago

Problem/Motivation

Replace hardcoded database queries with dynamic queries to support MongoDB as MongoDB does not support SQL queries. We should not replace hardcoded database queries when those queries are in the critical path or are in the namespace Drupal\KernelTests\Core\Database. The hardcoded database queries in the namespace Drupal\KernelTests\Core\Database are for testing the dynamic queries.

Proposed resolution

Replace hardcoded database queries with dynamic queries.

Remaining tasks

TBD

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

None

๐Ÿ“Œ Task
Status

Fixed

Version

11.0 ๐Ÿ”ฅ

Component
Databaseย  โ†’

Last updated 3 minutes ago

  • Maintained by
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands @daffie
Created by

๐Ÿ‡ณ๐Ÿ‡ฑNetherlands daffie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @daffie
  • Merge request !9540Resolve #3475512 "Replace hardcoded database" โ†’ (Closed) created by daffie
  • Pipeline finished with Failed
    3 months ago
    Total: 1048s
    #287117
  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands daffie
  • Pipeline finished with Success
    3 months ago
    Total: 4174s
    #287149
  • Status changed to RTBC 3 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    I'm having to do the exact same thing on a number of modules but refactors seem to be good 1to1

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Love thisโ€ฆ I wonder how far would we be from deprecating usage of hardcoded static queries from non-test, non-database core code. +1

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Not sure if there is a page somewhere but would be cool to see the all sql queries keywords with their dyanmic counterparts

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    #6 well the Database API documentation and https://www.drupal.org/docs/8/api/database-api/dynamic-queries โ†’ in particular covers that pretty well already, IMO

  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    OK I was expecting a big MR, but this is actually very minimal.

    Not 100% sure about dblog though, wouldn't it make more sense to provide mongodb_log since I would imagine the stored format of the messages could then be optimised?

  • Pipeline finished with Success
    3 months ago
    Total: 564s
    #288818
  • Status changed to RTBC 3 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands daffie

    @catch: We have changed a lot of hardcoded SQL queries to dynamic queries in the past. If you want, I will go and search for those issues. These are the hardcoded queries that are left. The remaining ones are mostly in Drupal's critical path.
    I am at the moment still in the phase of getting Drupal on MongoDB to support all the features. Drupal on MongoDB now is at a 99% pass rate for the CI pipeline ๐Ÿ“Œ Drupal on MongoDB (the full PR) Active . Sooner or later I will get the phase where MongoDB specific improvements will be added. I am still not at the point where I have an official go for Drupal on MongoDB from the Drupal Core committer team. :)

    • catch โ†’ committed 7d4bba32 on 11.x
      Issue #3475512 by daffie: Replace hardcoded database queries with...
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    We have changed a lot of hardcoded SQL queries to dynamic queries in the past.

    Yes I remember that, I just though it would be worse than this even with those issues having landed already ;) Remaining ones are in database cache backend etc.

    Even though I'm not sure dblog-on-mongodb makes sense in practice, it doesn't hurt to make it work. Committed/pushed to 11.x, thanks!

  • Status changed to Fixed 3 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024