Menu

#257 Wrong type conversion in SELECTs using "AS 'fieldName'"

Fixed
nobody
None
Problematic
Defect
2008-07-14
2008-05-26
Anonymous
No

Originally created by: a...@anse.de
Originally owned by: a...@anse.de

Reported as bug #1830516 by dragos_dobrota@sf on 2007-11-12 08:09

DROP TABLE IF EXISTS `mytable`;
CREATE TABLE `mytable` (
  `id` int(10) NOT NULL auto_increment,
  `name` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `mytable` VALUES(1, "lala");

SELECT `mytable`.name AS 'id' FROM `mytable`;

This will display 0 instead of the data in field 'name'. Apparently the
program confuses the alias 'id' with the table field 'id' and attempts to
convert mytable.name to its type (string to int).

If I issue:
SELECT `mytable`.name AS 'idX' FROM mytable;
the output is the correct one.

I think it works with any table w/ an int and non int fields like this (the
conversion is from non-int to int)

Tested against Heidi 3.0 and Heidi 3.1 RC1 build 1064 (latest).

**** Comment 1 by dragos_dobrota@sf, 2007-11-12 08:14

Forgot to say.
Using MySQL 5.0.37 and same SQL works as expected in "MySQL Query
Browser".

**** Comment 2 by dragos_dobrota@sf, 2007-11-12 08:36

Forgot to say.
Using MySQL 5.0.37 and same SQL works as expected in "MySQL Query
Browser".

**** Comment 3 by dragos_dobrota@sf, 2007-11-12 09:34

Forgot to say.
Using MySQL 5.0.37 and same SQL works as expected in "MySQL Query
Browser".

**** Comment 4 by ansgarbecker@sf, 2007-11-12 11:29

Can comfirm that issue.

Runs well:
SELECT name AS id FROM mytable
SELECT name AS 'idX' FROM mytable

Bug:
SELECT name AS 'id' FROM mytable

Discussion

  • Anonymous

    Anonymous - 2008-05-28

    Originally posted by: rosenfie...@gmail.com

    (No comment was entered for this change.)

    Labels: Severity-Problematic

     
  • Anonymous

    Anonymous - 2008-05-28

    Originally posted by: rosenfie...@gmail.com

    (No comment was entered for this change.)

    Labels: -Priority-Low

     
  • Anonymous

    Anonymous - 2008-05-30

    Originally posted by: a...@anse.de

    (No comment was entered for this change.)

    Labels: -migrated

     
  • Anonymous

    Anonymous - 2008-07-11

    Originally posted by: rosenfie...@gmail.com

    I'm pretty sure this is caused by the same code path that caused issue #315.

     

    Related

    Tickets: #315

MongoDB Logo MongoDB