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

VALUES not accessible by variable name in ON DUPLICATE KEY UPDATE #1225

Closed
oscarbatori opened this issue Jan 17, 2021 · 7 comments
Closed

VALUES not accessible by variable name in ON DUPLICATE KEY UPDATE #1225

oscarbatori opened this issue Jan 17, 2021 · 7 comments
Assignees

Comments

@oscarbatori
Copy link
Contributor

It seems that although we support ON DUPLICATE KEY UPDATE, we do not provide access to the VALUES by variable which is normally how that statement is used:

query = b"INSERT INTO characters (name, adjective, id, date_of_death) VALUES ('Anna', 'tragic', 1, '1877-01-01 00:00:00'), ('V...ULL) ON DUPLICATE KEY UPDATE name = VALUES(name), adjective = VALUES(adjective), date_of_death = VALUES(date_of_death)"
raw = False, buffered = False, raw_as_string = False

    def cmd_query(self, query, raw=None, buffered=False, raw_as_string=False):
        """Send a query to the MySQL server"""
        self.handle_unread_result()
        if raw is None:
            raw = self._raw
        try:
            if not isinstance(query, bytes):
                query = query.encode('utf-8')
>           self._cmysql.query(query,
                               raw=raw, buffered=buffered,
                               raw_as_string=raw_as_string)
E                              _mysql_connector.MySQLInterfaceError: unknown error: unsupported syntax: values(name)

../../../../../anaconda3/envs/doltpy-dev/lib/python3.8/site-packages/mysql/connector/connection_cext.py:487: MySQLInterfaceError
@oscarbatori
Copy link
Contributor Author

@Hydrocharged got a ETA on this one?

@Hydrocharged
Copy link
Contributor

What would you say the priority is for it?

@oscarbatori
Copy link
Contributor Author

It's bug in my view, since it renders the most common use-case for the feature not really usable... unless I am missing some way of accessing the values tuple by name?

@timsehn
Copy link
Contributor

timsehn commented Jan 22, 2021 via email

@Hydrocharged
Copy link
Contributor

@oscarbatori dolthub/go-mysql-server#273
VALUES() has been recently deprecated, although we don't support the updated syntax either (#4479), so I went ahead and implemented this as it's the simpler of the two to do, just so you have something to work with in the meantime.

@oscarbatori
Copy link
Contributor Author

@Hydrocharged so to be clear we do support the VALUES() syntax that is deprecated?

I agree with the linked issue that this is recently deprecated enough such that we should support it. In particular we are using it via clients that generate SQL in the legacy syntax.

@Hydrocharged
Copy link
Contributor

Yes, the referenced PR is adding the functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants