-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '5.4' of https://github.com/lucee/Lucee into 5.4
- Loading branch information
Showing
5 changed files
with
144 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,79 @@ | ||
component extends="org.lucee.cfml.test.LuceeTestCase" skip="false" labels="qoq" { | ||
component extends="org.lucee.cfml.test.LuceeTestCase" skip="true" labels="qoq" { | ||
|
||
variables.db = server.getDatasource( "h2", server._getTempDir( "ldev-4181" ) ); | ||
// server.getDatasource("mysql"); | ||
|
||
function beforeAll(){ | ||
if ( !hasDb() ) | ||
return; | ||
afterAll(); | ||
queryExecute( | ||
sql="CREATE TABLE ldev4181 ( | ||
id numeric(11,10) NOT NULL, | ||
price decimal(10,2) | ||
) ", | ||
options: { | ||
datasource: variables.db | ||
} | ||
); | ||
}; | ||
|
||
function afterAll(){ | ||
if ( !hasDb() ) | ||
return; | ||
queryExecute( | ||
sql="drop table if exists ldev4181", | ||
options: { | ||
datasource: variables.db | ||
} | ||
); | ||
|
||
}; | ||
|
||
private function hasDb(){ | ||
return !isEmpty(variables.db); | ||
} | ||
|
||
function run( testResults , testBox ) { | ||
describe( title="Testcase for LDEV-4181", body=function() { | ||
it(title="Checking QoQ with numeric column", body = function( currentSpec ) { | ||
it(title="Checking QoQ with numeric column, trailing 000s", body = function( currentSpec ) { | ||
var qry = queryNew( 'id,test', 'numeric,string', [ [1,',1,10'],[2,',2,20'],[3,',3,30'],[4,',4,40'],[5,',5,50'],[10,',10,100'],[15,',15,150'] ] ); | ||
var queryResult = queryExecute(" | ||
SELECT id | ||
FROM qry | ||
SELECT id | ||
FROM qry | ||
where ','||test||',' like ('%1%')", | ||
[], | ||
{ dbType='query' } | ||
); | ||
expect(valueList(queryResult.id)).tobe("1,10,15"); | ||
}); | ||
|
||
it(title="Checking mysql query with numeric column, trailing 000s", body = function( currentSpec ) { | ||
var price = 3.14; | ||
queryExecute( | ||
sql="INSERT INTO ldev4181 ( id, price ) VALUES ( :id, :price )", | ||
params={ | ||
id: { value: 1, type: "int" }, | ||
price: { value: price, type: "decimal" } | ||
}, | ||
options: { | ||
datasource: variables.db | ||
} | ||
); | ||
|
||
var qry = queryExecute( | ||
sql: "SELECT * from ldev4181", | ||
options: { | ||
datasource: variables.db | ||
} | ||
); | ||
|
||
expect( qry.recordCount ).toBe ( 1 ); | ||
expect( qry.toJson() ).toBe('{"COLUMNS":["id","price"],"DATA":[[1,3.14]]}'); | ||
expect( valueList(qry.id ) ) .toBe( "1" ); | ||
expect( qry.id.toString() ).toBe( 1 ); | ||
expect( qry.price ).toBe( price ); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq" { | ||
|
||
function run( testResults , testBox ) { | ||
|
||
describe( title='QofQ' , body=function(){ | ||
|
||
it( title='QoQ check decimal types scale are preserved' , body=function() { | ||
var dec = 5.57; | ||
var q1 = QueryNew( "id,dec", "integer,decimal" ); | ||
q1.addRow( { id: 1, dec: dec } ); | ||
var q2 = QueryNew( "id,str", "integer,varchar" ); | ||
q2.addRow( { id: 1, str: "testing" } ); | ||
|
||
var q3sql = " | ||
select q1.* | ||
from q1, q2 | ||
where q1.id = q2.id | ||
"; | ||
var q3 = QueryExecute( q3sql, {}, {dbtype: "query"} ); | ||
// q3.dec should be 5.57. It was 6 instead. | ||
expect( q3.dec ).toBe( dec ); | ||
|
||
var q4sql = " | ||
select * | ||
from q1, q2 | ||
where q1.id = q2.id | ||
"; | ||
var q4 = QueryExecute( q4sql, {}, {dbtype: "query"} ); | ||
// q4.dec should be 5.57. It was 6 instead. | ||
expect( q4.dec ).toBe( dec ); | ||
}); | ||
}); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq" { | ||
|
||
function beforeAll(){ | ||
variables.q = queryNew("navid, type, url", "varchar,decimal,VarChar", | ||
[{ | ||
"navid": 200, | ||
"type": 1, | ||
"url": "football" | ||
} | ||
] | ||
); | ||
}; | ||
|
||
function run( testResults , testBox ) { | ||
|
||
describe( title='QofQ' , body=function(){ | ||
|
||
it( title='QoQ error with types and subselect' , body=function() { | ||
|
||
query name="local.res" dbtype="query" { | ||
echo(" | ||
select navid, type, url | ||
from variables.q | ||
where url = 'football' | ||
and type = 1 | ||
and left( navid, 3 ) in ( | ||
select navid | ||
from variables.q | ||
where type = 1 | ||
and url = 'football') | ||
"); | ||
} | ||
expect( res.recordcount ).toBe( 1 ); | ||
}); | ||
|
||
}); | ||
|
||
} | ||
|
||
} |