[Sqlalchemy-tickets] Issue #4222: Query yields different result via SQLA than via mysql command lin
Brought to you by:
zzzeek
From: dwt <iss...@bi...> - 2018-03-21 17:01:46
|
New issue 4222: Query yields different result via SQLA than via mysql command line client https://bitbucket.org/zzzeek/sqlalchemy/issues/4222/query-yields-different-result-via-sqla dwt: Hi there, I have to admit I'm really not sure where this bug is - but at least I could simmer it down to this reproduction that might be helpful to fix it. First some context: I recently wrote a migration that had a query like this: ```sql select seq, replace(uuid(), "-", "") from seq_0_to_9 ``` which works beautifully from the mysql (mariadb actually) command line client, in that it returns a sequence of UUIDs that are all different. However, when executed through sqlalchemy, this query returns the same UUID for each result line. Here's my reduction: ```python #!/usr/bin/env python """ Versions: mysql Ver 15.1 Distrib 10.2.13-MariaDB, for osx10.13 (x86_64) using readline 5.1 PyMySQL==0.8.0 SQLAlchemy==1.2.5 """ import sqlalchemy as sa from sqlalchemy import sql from pprint import pprint engine = sa.create_engine('mysql+pymysql://test:test@localhost/test?charset=utf8mb4', echo=True) pprint(engine.execute('select seq, uuid() from seq_0_to_9').fetchall()) pprint(engine.execute('select seq, replace(uuid(), "-", "") from seq_0_to_9').fetchall()) """ The two queries produce different output, in that the second query returns one and the same UUID for each row, while the first returns a different UUID for each row. To the best of my understanding the two queries should return a different UUID for each row - and that is also the behaviour I get when I do this from the mysql command line client. """ ``` |