Skip to content

Commit

Permalink
Quick fixes for Oracle grammar. Still needs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Dec 21, 2016
1 parent e4146cb commit 74e14f7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
18 changes: 12 additions & 6 deletions models/Query/Grammars/Grammar.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,12 @@ component displayname="Grammar" accessors="true" {

private string function wrapTable( required any table ) {
var alias = "";
if ( table.find( " as " ) ) {
alias = wrapTable( table.listToArray( " as ", false, true )[ 2 ] );
table = table.listToArray( " as ", false, true )[ 1 ];
if ( table.findNoCase( " as " ) > 0 ) {
var matches = REFindNoCase( "(.*)(?:\sAS\s)(.*)", table, 1, true );
if ( matches.pos.len() >= 3 ) {
alias = mid( table, matches.pos[3], matches.len[3] );
table = mid( table, matches.pos[2], matches.len[2] );
}
}
table = table.listToArray( "." ).map( function( tablePart, index ) {
return wrapValue( index == 1 ? getTablePrefix() & tablePart : tablePart );
Expand All @@ -273,9 +276,12 @@ component displayname="Grammar" accessors="true" {
return column.getSQL();
}
var alias = "";
if ( column.find( " as " ) ) {
alias = column.listToArray( " as ", false, true )[ 2 ];
column = column.listToArray( " as ", false, true )[ 1 ];
if ( column.findNoCase( " as " ) > 0 ) {
var matches = REFindNoCase( "(.*)(?:\sAS\s)(.*)", column, 1, true );
if ( matches.pos.len() >= 3 ) {
alias = mid( column, matches.pos[3], matches.len[3] );
column = mid( column, matches.pos[2], matches.len[2] );
}
}
column = column.listToArray( "." ).map( wrapValue ).toList( "." );
return alias == "" ? column : column & " AS " & wrapValue( alias );
Expand Down
18 changes: 18 additions & 0 deletions models/Query/Grammars/OracleGrammar.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,23 @@ component extends="qb.models.Query.Grammars.Grammar" {
return "";
}

private string function wrapTable( required any table ) {
var alias = "";
if ( table.findNoCase( " as " ) > 0 ) {
var matches = REFindNoCase( "(.*)(?:\sAS\s)(.*)", table, 1, true );
if ( matches.pos.len() >= 3 ) {
alias = mid( table, matches.pos[3], matches.len[3] );
table = mid( table, matches.pos[2], matches.len[2] );
}
}
table = table.listToArray( "." ).map( function( tablePart, index ) {
return wrapValue( index == 1 ? getTablePrefix() & tablePart : tablePart );
} ).toList( "." );
return alias == "" ? table : table & " " & wrapValue( alias );
}

private string function wrapValue( required any value ) {
return super.wrapValue( uCase( arguments.value ) );
}

}

0 comments on commit 74e14f7

Please sign in to comment.