0

I am getting mysql error in github actions which I need to fix:

<!-- An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1055 
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'xxx'
which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (500 Internal Server Error) -->

To fix this I need to run something like this:

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

My question is where and how do I run this command in github actions yml file ?

jobs:
  main:
    runs-on: ubuntu-latest

    steps:
      - name: Install PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.4.28'
          extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
          coverage: xdebug

      - name: Start Mysql
        run: sudo /etc/init.d/mysql start

      - uses: actions/checkout@v1

       ....
gp_sflover
  • 3,460
  • 5
  • 38
  • 48
talhaamir
  • 99
  • 2
  • 15
  • The error message tells that your query text is incorrect. So you must fix the problematic query, not SQL mode which allows to execute this incorrect query due to MySQL extension - anycase the values in problematic output expressions makes no sense because they're indefinitely selected from the group values list. It is necessary to treat the disease, not its symptoms. – Akina May 24 '22 at 05:42
  • @Akina Thanks for this feedback. In my case when I run this query locally or in production with doctrine I never get this error, but only in github actions. That is why I want to fix it only in github actions. Even when I run phpunit test locally I get ok result, but in github actions I get this error. – talhaamir May 24 '22 at 06:08
  • *That is why I want to fix it only in github actions.* This is an incorrect intention. Read the last sentence from my comment one more time. – Akina May 24 '22 at 07:23
  • The mysql database provided by Github Actions is incompatible with your needs. You can use a custom Docker image for MySQL (according to your needs). – qdequippe May 24 '22 at 13:49

1 Answers1

1

Add additional query in starting mysql:


      - name: Start Mysql
        run: |
          sudo /etc/init.d/mysql start
          mysql -u root --password=mypassword -e "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));"

talhaamir
  • 99
  • 2
  • 15