Search code examples
mysqlgoogle-cloud-platformgoogle-cloud-sql

Google Cloud SQL / mysql Who is right?


I ordered custom ERP app development (not very complex) from a developer company. I want it to run on GCP (Cloud Run for the PHP code /yii/, Cloud SQL for MySQL, Cloud Storage for files).

DevOps says: At Google Cloud SQL, it's not possible to disable ONLY_FULL_GROUP_BY, and even make it possible with some "hack" defenetly not suggested.

Developer: The developer says that they need to disable ONLY_FULL_GROUP_BY. (the company develop only for linux or windows server, and if they change it it won't work on they windos server, and this is completly different envirement, and for this request need a completly differnet agreement)

Can you help me figure out who is right? (I'm not a programer, but I want to run my app on a stable envoirement, like gcp)

I tried to ask developer to add the fileds for the select list what he want to use for group by. but as not a programer I'm not sure if this is the right question.


Solution

  • There are two ways to answer this question:

    1. It's always possible to change the sql_mode to omit ONLY_FULL_GROUP_BY as a session variable. The client (i.e. an application) can do this after it connects to the database. This option will only be in effect for that session, but there is nothing preventing the application from doing it for every session where it is needed.

    2. In my opinion, it's always better to leave the ONLY_FULL_GROUP_BY mode enabled. Disabling it creates a risk of ambiguous query results. I posted an example to explain why in my answer to this question:

      Reason for Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause

      It's hard to believe that the developer can't write proper code that works with ONLY_FULL_GROUP_BY enabled. In fact, if they were using a database other than MySQL, MariaDB, or SQLite, it isn't even possible to disable enforcement of the single-value rule (i.e. developers who use PostgreSQL, Oracle, Microsoft SQL Server, or any other SQL database have been following this rule just fine for decades). This makes me think your developer's SQL skills aren't so good.