Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix issue #64 #1131

Merged
merged 2 commits into from

2 participants

@tiyowan

Modify regular expression to be able to handle SQL bracket delimiters for
column names that contain special characters or SQL keywords.

Signed-off-by: Hamza Bhatti tiyowan@gmail.com

@tiyowan tiyowan Fix issue #64
Modify regular expression to be able to handle SQL bracket delimiters for
column names that contain special characters or SQL keywords.

Signed-off-by: Hamza Bhatti <tiyowan@gmail.com>
d3c1ccf
@philsturgeon

Could you give an example of a SQL query that was breaking here?

@tiyowan

Reference from the issue tracker:

$querry = $this->db
->select( '[a]' )
->from( '[A]' )
->join( '[B]', '[A].[a] = [B].[b]' );

die($this->db->_compile_select());
Result
sql
SELECT [a] FROM [A] JOIN [B] ON A].[a] = [B].[b]

Expected
sql
SELECT [a] FROM [A] JOIN [B] ON [A].[a] = [B].[b]

Thanks,
Guillaume

@philsturgeon

Ok, but please add a changelog entry.

@tiyowan tiyowan Add changelog entry (bug fix for issue #64)
Signed-off-by: Hamza Bhatti <tiyowan@gmail.com>
2eee0aa
@tiyowan

Done?

@tiyowan tiyowan closed this
@tiyowan tiyowan reopened this
@philsturgeon philsturgeon merged commit 68c0173 into bcit-ci:develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 5, 2012
  1. @tiyowan

    Fix issue #64

    tiyowan authored
    Modify regular expression to be able to handle SQL bracket delimiters for
    column names that contain special characters or SQL keywords.
    
    Signed-off-by: Hamza Bhatti <tiyowan@gmail.com>
  2. @tiyowan

    Add changelog entry (bug fix for issue #64)

    tiyowan authored
    Signed-off-by: Hamza Bhatti <tiyowan@gmail.com>
This page is out of date. Refresh to see the latest.
View
2  system/database/DB_active_rec.php
@@ -341,7 +341,7 @@ public function join($table, $cond, $type = '')
$this->_track_aliases($table);
// Strip apart the condition and protect the identifiers
- if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match))
+ if (preg_match('/([\[\w\.]+)([\W\s]+)(.+)/', $cond, $match))
{
$cond = $this->_protect_identifiers($match[1]).$match[2].$this->_protect_identifiers($match[3]);
}
View
1  user_guide_src/source/changelog.rst
@@ -158,6 +158,7 @@ Release Date: Not Released
Bug fixes for 2.1.1
-------------------
+- Fixed a bug (#64) - Regular expression in DB_active_rec.php failed to handle queries containing SQL bracket delimiters in the join condition.
- Fixed a bug (#697) - A wrong array key was used in the Upload library to check for mime-types.
- Fixed a bug - form_open() compared $action against site_url() instead of base_url().
- Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE.
Something went wrong with that request. Please try again.