zend-db icon indicating copy to clipboard operation
zend-db copied to clipboard

Allow column names to contain any character

Open metalinspired opened this issue 8 years ago • 9 comments

In regards to issues #8 and #208 I've created a regex that will allow user to use any character as column name. It will also keep functionality of allowing user to enter 'column as alias' as column name. I've made an assumption that no one in right mind will have spaces on beginning or end of column name so they are ignored by regex.

metalinspired avatar May 28 '17 21:05 metalinspired

@metalinspired unit tests are missing for this PR, can you add it? Testing is very important here because you proposed a regex and we need to validate all the possible cases (or at least the most common). Thanks!

ezimuel avatar Jun 21 '17 10:06 ezimuel

@ezimuel I wouldn't know where to begin. The regex if written so that all existing tests are passing and as you can see I failed three times before succeeding. If the regex fails it will throw an exception and worse that can happen is malformed SQL syntax which was original problem to begin with. Personally I think that some of the undocumented behavior for column names, which I mentioned in #208, should be removed thus eliminating need for this patch.

metalinspired avatar Jun 21 '17 10:06 metalinspired

@metalinspired I'll try to work on this PR adding the unit test, thanks anyway for your contribution!

ezimuel avatar Jun 21 '17 10:06 ezimuel

@ezimuel Glad I could help

metalinspired avatar Jun 21 '17 10:06 metalinspired

Hey @froschdesign @ezimuel - May we have any update for this? We need this in one of our products. So it'll be a great help if this PR gets merged.

binal-7span avatar Oct 07 '19 12:10 binal-7span

@bjgajjar Still we need unit test for these changes. If you can provide these it will speed up the release. Thanks.

michalbundyra avatar Oct 07 '19 12:10 michalbundyra

@metalinspired - It seems like there is some issue here.

  • When tried to add a field named with @!#!12123123; DB will have a column with the name of @`!`#`!`12123123 instead of @!#!12123123
  • When adding any field with special character[@user_id] - Although it's getting stored in DB - It is throwing Unable to find field @user_id error with status code 404 instead of the success code with the JSON object of stored field.

binal-7span avatar Oct 09 '19 06:10 binal-7span

This repository has been moved to laminas/laminas-db. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:

  • Squash all commits in your branch (git rebase -i origin/{branch})
  • Make a note of all changed files (`git diff --name-only origin/{branch}...HEAD
  • Run the laminas/laminas-migration tool on the code.
  • Clone laminas/laminas-db to another directory.
  • Copy the files from the second bullet point to the clone of laminas/laminas-db.
  • In your clone of laminas/laminas-db, commit the files, push to your fork, and open the new PR. We will be providing tooling via laminas/laminas-migration soon to help automate the process.

weierophinney avatar Dec 31 '19 22:12 weierophinney

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at https://github.com/laminas/laminas-db/issues/70.

michalbundyra avatar Jan 16 '20 19:01 michalbundyra