Ticket #3 (closed defect: fixed)

Opened 5 years ago

Last modified 6 months ago

Add identifier quoting system.

Reported by: hans Owned by: hans
Priority: high Milestone: 1.3
Component: Generator Version: devel
Severity: normal Keywords: identifier, quoting, escaping
Cc: contact@…

Description

Add support for quoting identifiers (column / table names) in DDL and in the generated SQL.

Attachments

BasePeer.php.patch Download (1.5 KB) - added by simon 6 months ago.
Patch for BasePeer.php

Change History

comment:1 Changed 5 years ago by hans

  • Priority changed from normal to high

comment:2 Changed 5 years ago by anonymous

While I think this should be in Creole, not Propel, I'd propose you look into table prefixing while you're at it (table prefixes are important to ppl who pay their provider per DB and want to avoid table name clashes, eg).

comment:3 Changed 5 years ago by david

  • Milestone changed from 1.2 to 1.3

Table prefixing is already possible...

<table name="prefix_table" phpName="table">

comment:4 Changed 5 years ago by hans

Closed #154, which described the issue that this ticket addresses.

comment:5 Changed 5 years ago by hans

Closed #147, which also described this issue.

comment:6 Changed 4 years ago by StarQuake

Ah prefixing is also a solution to the escaping problem then :D

comment:7 Changed 3 years ago by david

#440 is a dupe

comment:8 Changed 3 years ago by hans

  • Milestone changed from 1.3 to 2.0

This has been half implemented (implemented in the Generator), but we cannot get a full runtime implementation with the current Criteria model. I'm moving this over to 2.0 for the "final fix".

comment:9 Changed 2 years ago by skyblaze@…

I would like to know if the identifiers quoting issue will be resolved in 1.3 or we have to wait so long until 2.0! Anyway the prefixing option for table names is good but we also have identifiers problems on column name...so we propbably should prefix column names also?

comment:10 Changed 2 years ago by hans

Correcting my comment:

My belief is this is mostly working in 1.3; however, I need to check on this before we decide if we're going to consider this resolved. I know there are some fringe cases that aren't going to be completely handled in 1.3, due to the way that table + column names are stored as strings within the peer classes. For example, when these strings are used together in (e.g.) custom criteria, it becomes very difficult to correctly quote the identifiers. This is the part that will need to wait for Criteria2 when we will have a better way to represent columns that will allow for better runtime quoting and aliasing.

comment:11 Changed 2 years ago by hans

  • Status changed from new to assigned
  • Milestone changed from 2.0 to 1.3

I think this is actually missing from appendPsTo() right now, which means select columns aren't being quoted. I will assess the possibility of fixing this for 1.3 -- at least taking a good stab at it.

comment:12 Changed 2 years ago by hans

  • Status changed from assigned to closed
  • Resolution set to fixed

The note about appendPsTo() actually doesn't really apply to this. I guess it was early in the AM. :) After some review, I'm going to close this issue; it is not completely fixed because the quoting won't work for Postgres, but this is because quoting means different things for different layers -- and it means case-sensitivity for Postgresql.

comment:13 Changed 6 months ago by simon

  • Cc contact@… added
  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Component changed from Generator to Runtime (PHP5)
  • Milestone changed from 1.3 to 1.5

If you use a table name with the name is a reserved word (bad practise ;-) ) the request isn't correctly escaped. For example, with MySQL use the table name : "group"

The table name would be escaped for all request. Show in attachment a patch for the file runtime/lib/util/BasePeer.php

Changed 6 months ago by simon

Patch for BasePeer.php

comment:14 Changed 6 months ago by francois

  • Status changed from reopened to closed
  • Resolution set to fixed
  • Component changed from Runtime (PHP5) to Generator
  • Milestone changed from 1.5 to 1.3

Could you please create a new ticket for this issue?

Note: See TracTickets for help on using tickets.