简体   繁体   中英

Propel not adding single quote to fields name in MySql query

I have the following mysql table:

CREATE TABLE `content_segments`
(
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `include` TINYINT(1) NOT NULL,
    `dimension` VARCHAR(50) NOT NULL,
    `media_type` VARCHAR(50) NOT NULL,
    `match` VARCHAR(50) NOT NULL,
    `content` TEXT NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=MyISAM;

The problem is the match field is reserved word in MySQL, and propel2 doesn't surround the fields name with a single quote to escape the reserved word at run-time (when the query is generated). I wonder if there's a why to force propel escaping all my table fields with single quote to avoid reserved words errors. The error I'm getting is this:

Unable to execute SELECT statement [SELECT id, include, dimension, media_type, match, content FROM content_segments WHERE id = :p0]

The solution is in the issue discussion on propel git repository.

We have changed the way how identifier quoting is working. You need to activate it per database or per table:

<database ... identifierQuoting="true">
or
<table ... identifierQuoting="true">

As it was stated in the comment of the question, the related propel issue is https://github.com/propelorm/Propel2/issues/781 for propel2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM