Skip to content

Commit

Permalink
Merge branch '5.4' of https://github.com/lucee/Lucee into 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Sep 15, 2023
2 parents 10bcb41 + c6084bf commit 19d77b8
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,7 @@ private static void _loadDataSources(ConfigServerImpl configServer, ConfigImpl c
try {
setDatasource(config, datasources, QOQ_DATASOURCE_NAME,
new ClassDefinitionImpl("org.hsqldb.jdbcDriver", "org.lucee.hsqldb", "2.7.2.jdk8", config.getIdentification()), "hypersonic-hsqldb", "", -1,
"jdbc:hsqldb:mem:tempQoQ;sql.regular_names=false;", "sa", "", null, DEFAULT_MAX_CONNECTION, -1, -1, 60000, true, true, DataSource.ALLOW_ALL, false, false, null, new StructImpl(), "",
"jdbc:hsqldb:mem:tempQoQ;sql.regular_names=false;sql.enforce_strict_size=false;sql.enforce_types=false;", "sa", "", null, DEFAULT_MAX_CONNECTION, -1, -1, 60000, true, true, DataSource.ALLOW_ALL, false, false, null, new StructImpl(), "",
ParamSyntax.DEFAULT, false, false, false, false);

}
Expand Down
77 changes: 1 addition & 76 deletions core/src/main/java/resource/fld/core-lucee.fld
Original file line number Diff line number Diff line change
Expand Up @@ -326,38 +326,6 @@ You can find a list of all available timezones in the Lucee administrator (Setti
</return>
</function>

<!-- CurrencyFormat -->
<function>
<name>CurrencyFormat</name>
<class>lucee.runtime.functions.international.CurrencyFormat</class>
<keywords>date,string,formatting</keywords>
<description>Formats a number in a locale-specific currency format.</description>
<argument>
<name>number</name>
<alias>currency_number</alias>
<type>object</type>
<required>Yes</required>
<description>Currency value</description>
</argument>
<argument>
<name>type</name>
<type>string</type>
<required>No</required>
<default>local</default>
<description></description>
</argument>
<argument>
<name>locale</name>
<type>locale</type>
<required>No</required>
<description>Locale to use instead of the locale of the page when processing the function</description>
</argument>
<return>
<type>string</type>
</return>
</function>


<!-- IsCurrency -->
<function>
<name>IsCurrency</name>
Expand Down Expand Up @@ -650,50 +618,7 @@ The function follows Java date time mask. For details, see the section Date and
<type>number</type>
</return>
</function>
<!-- TimeFormat -->
<function>
<name>TimeFormat</name>
<class>lucee.runtime.functions.international.TimeFormat</class>
<keywords>date,string,formatting</keywords>
<description>Formats a time string to a given output using the current locale.</description>
<argument>
<name>time</name>
<type>any</type>
<required>Yes</required>
<description>date object</description>
</argument>
<argument>
<name>mask</name>
<type>string</type>
<required>No</required>
<default>short</default>
<description></description>
</argument>
<argument>
<name>locale</name>
<type>locale</type>
<required>No</required>
<description>Locale to use instead of the locale of the page when processing the function</description>
</argument>
<argument>
<name>timezone</name>
<type>timezone</type>
<required>No</required>
<description>
A datetime object is independent of a specific timezone, it is only an offset in milliseconds from 1970-1-1 00.00:00 UTC (Coordinated Universal Time).
This means that the timezone only comes into play when you need specific information like hours in a day, minutes in a hour or which day it is since those calculations depend on the timezone.
For these calculations, a timezone must be specified in order to translate the date object to something else. If you do not provide the timezone in the function call, it will default to the timezone specified in the Lucee Administrator (Settings/Regional), or the timezone specified for the current request using the function setTimezone.
You can find a list of all available timezones in the Lucee administrator (Settings/Regional). Some examples of valid timezones:
- AGT (for time in Argentina)
- Europe/Zurich (for time in Zurich/Switzerland)
- HST (Hawaiian Standard Time in the USA)
</description>
</argument>
<return>
<type>string</type>
</return>
</function>


<!-- monthShortAsString -->
<function>
<name>monthShortAsString</name>
Expand Down
70 changes: 66 additions & 4 deletions test/tickets/LDEV4181.cfc
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 );
});
});
}
}
36 changes: 36 additions & 0 deletions test/tickets/LDEV4691.cfc
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 );
});
});

}

}
40 changes: 40 additions & 0 deletions test/tickets/LDEV4695.cfc
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 );
});

});

}

}

0 comments on commit 19d77b8

Please sign in to comment.