Skip Menu |

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 90466
Status: resolved
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: ROBN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.11018
Fixed in: 0.11019



Subject: MySQL CURRENT_TIMESTAMP emitted as SCALAR(0x...)
Sorry, not entirely sure how to describe this, so here's some examples: This fails: $ cat x.sql CREATE TABLE foo ( bar TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); $ sqlt -f MySQL -t MySQL x.sql -- -- Created by SQL::Translator::Producer::MySQL -- Created on Mon Nov 18 13:24:12 2013 -- SET foreign_key_checks=0; -- -- Table: `foo` -- CREATE TABLE `foo` ( `bar` TIMESTAMP on update SCALAR(0x315a940) NULL ); SET foreign_key_checks=1; This appears to succeed: $ cat x.sql CREATE TABLE foo ( bar TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); $ sqlt -f MySQL -t MySQL x.sql -- -- Created by SQL::Translator::Producer::MySQL -- Created on Mon Nov 18 13:24:50 2013 -- SET foreign_key_checks=0; -- -- Table: `foo` -- CREATE TABLE `foo` ( `bar` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ); SET foreign_key_checks=1; But not always: $ sqlt -f MySQL -t POD x.sql ... =item * TIMESTAMP =item * Default 'SCALAR(0x250e480)' =item * Nullable 'Yes' ... Its not clear to me if this is a parser or producer bug.
Subject: Re: [rt.cpan.org #90466] AutoReply: MySQL CURRENT_TIMESTAMP emitted as SCALAR(0x...)
Date: Tue, 19 Nov 2013 19:01:42 -0800
To: "Bugs in SQL-Translator via RT" <bug-SQL-Translator [...] rt.cpan.org>
From: Robert Norris <rob [...] eatenbyagrue.org>
I figured this out. The parser will always generate a scalar reference for CURRENT_TIMESTAMP (to avoid quoting), but it only dereferences it for DEFAULT, not for ON UPDATE, causing producers to emit SCALAR(0x........) instead. Here's a patch: https://github.com/fastmail/sql-translator/commit/fe247ad2028a1cb980a2118e73e051e0cf6ae210 All it does is dereference scalar references when emitting values for extra fields. It's only for MySQL and won't help other producers at all.