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

Untangles the control of the casing and quoting of columns #864

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mnewnham
Copy link
Contributor

@mnewnham mnewnham commented Sep 4, 2022

Note that there is only MySQL driver change. If you think this works, I'll do all the others

The casing of table, column and index names are incorrectly linked to the casing of returned associative array keys and the field quoting performed, see #792. This change separates the feature into distinct methods solely for the feature, and deprecates previous methodologies

@dregad , I am quite happy with the way this has turned out. This removes all of the previous methods of controlling the casing and quoting in core, data dictionary and active records, and replaces all of it with just 2 ADOConnection methods:

$db->setQuoteStyle($integer); // 0 = No quoting, 1 = Normal Quotes e.g. backtick for MySQL
$db->setElementCase($integer) // 0 = No change 1 = Lower Case 2 = UpperCase

So looking at a CreateTableSQL, we can see the changes

Quoting = 0, Casing = 0

Array
(
    [0] => CREATE TABLE quote_test (
COL1                     VARCHAR(32) NOT NULL DEFAULT 'abc',
COL2                     INTEGER NOT NULL AUTO_INCREMENT,
COL3                     NUMERIC(12,2),
COL4                     VARCHAR(64),
COL5                     ENUM('cats','dogs','fish'),
col6                     VARCHAR(10),
`col 7`                  VARCHAR(10), // <--------------------------- Auto quoted because of space in name
                 PRIMARY KEY (COL2)
)
)

Quoting = 1, Casing = 1

Array
(
    [0] => CREATE TABLE `quote_test` (
`col1`                   VARCHAR(32) NOT NULL DEFAULT 'abc',
`col2`                   INTEGER NOT NULL AUTO_INCREMENT,
`col3`                   NUMERIC(12,2),
`col4`                   VARCHAR(64),
`col5`                   ENUM('cats','dogs','fish'),
`col6`                   VARCHAR(10),
`col 7`                  VARCHAR(10),
                 PRIMARY KEY (`col2`)
)
)

Quoting = 1 Casing = 2

Array
(
    [0] => CREATE TABLE `QUOTE_TEST` (
`COL1`                   VARCHAR(32) NOT NULL DEFAULT 'abc',
`COL2`                   INTEGER NOT NULL AUTO_INCREMENT,
`COL3`                   NUMERIC(12,2),
`COL4`                   VARCHAR(64),
`COL5`                   ENUM('cats','dogs','fish'),
`COL6`                   VARCHAR(10),
`COL 7`                  VARCHAR(10),
                 PRIMARY KEY (`COL2`)
)
)

The casing of table, column and index names are incorrectly linked to the casing of returned associative array keys and the field quoting performed, see #792. This change separates the feature into distinct methods solely for the feature, and deprecates previous methodologies
@mnewnham mnewnham added bug core ADOdb core (library and base classes) active record The ADOdb Active Record System labels Sep 4, 2022
@mnewnham mnewnham requested a review from dregad September 4, 2022 01:23
@mnewnham mnewnham linked an issue Sep 4, 2022 that may be closed by this pull request
@dregad
Copy link
Member

dregad commented Sep 4, 2022

Thanks for picking that one up! It seems promising, right along the lines of what I had in mind. I'll have a look and test in the next few days.

@mnewnham
Copy link
Contributor Author

mnewnham commented Sep 7, 2022

This would also appear to resolve #685 and #745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
active record The ADOdb Active Record System bug core ADOdb core (library and base classes)
Projects
None yet
2 participants