Skip to content

Commit

Permalink
Merge branch '6.2' of https://github.com/lucee/Lucee into 6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Jan 3, 2025
2 parents 8400671 + 54cfe40 commit 9f0ef41
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 54 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ jobs:
sudo -u postgres psql -c 'create database lucee;'
sudo -u postgres psql -c "create user lucee with encrypted password 'lucee'";
sudo -u postgres psql -c 'grant all privileges on database lucee to lucee;'
sudo -u postgres psql -c 'grant all on schema public to lucee;' -d lucee
- name: Start MongoDB (docker)
uses: supercharge/[email protected]
with:
Expand Down
114 changes: 60 additions & 54 deletions test/tags/dbInfo.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" {
createSchema( ds, dbtype, prefix );

describe( title="Test suite for DBINFO, db: [#dbType#]", body=function() {

it(title = "dbinfo columns [#dbType#]",
data = { prefix: prefix, ds: ds, dbtype: dbtype },
body = function( data ) {
Expand Down Expand Up @@ -167,75 +168,80 @@ component extends="org.lucee.cfml.test.LuceeTestCase" {

private void function createSchema( struct ds, string dbType, string prefix, boolean onlyDrop=false ){

try {

if (arguments.dbtype eq "oracle") { // oracle doesn't support the IF EXISTS syntax
try {
if (arguments.dbtype eq "oracle") { // oracle doesn't support the IF EXISTS syntax
try {
query datasource=arguments.ds {
echo("DROP view #arguments.prefix#v_users");
}
} catch(e){
//
}
try {
query datasource=arguments.ds {
echo("DROP TABLE #arguments.prefix#users");
}
} catch(e){
//
}
try {
query datasource=arguments.ds {
echo("DROP TABLE #arguments.prefix#roles");
}
} catch(e){
//
}
} else {
query datasource=arguments.ds {
echo("DROP view #arguments.prefix#v_users");
echo("DROP view IF EXISTS #arguments.prefix#v_users");
}
} catch(e){
//
}
try {
query datasource=arguments.ds {
echo("DROP TABLE #arguments.prefix#users");
echo("DROP TABLE IF EXISTS #arguments.prefix#users");
}
} catch(e){
//
}
try {
query datasource=arguments.ds {
echo("DROP TABLE #arguments.prefix#roles");
echo("DROP TABLE IF EXISTS #arguments.prefix#roles");
}
} catch(e){
//
}
} else {

if ( arguments.onlyDrop )
return;

query datasource=arguments.ds {
echo("CREATE TABLE #arguments.prefix#roles (
role_id INT,
role_name VARCHAR(100) DEFAULT NULL,
CONSTRAINT PK_#arguments.prefix#roles PRIMARY KEY ( role_id )
)");
}
query datasource=arguments.ds {
echo("DROP view IF EXISTS #arguments.prefix#v_users");
echo("CREATE TABLE #arguments.prefix#users (
user_id VARCHAR(50) NOT NULL,
user_name VARCHAR(50) NOT NULL,
role_id INT DEFAULT NULL,
CONSTRAINT PK_#arguments.prefix#users PRIMARY KEY ( user_id )
)");
}
query datasource=arguments.ds {
echo("DROP TABLE IF EXISTS #arguments.prefix#users");
echo("ALTER TABLE #arguments.prefix#users
ADD CONSTRAINT fk_#arguments.prefix#_user_role_id
FOREIGN KEY (role_id)
REFERENCES #arguments.prefix#roles ( role_id )");
}
query datasource=arguments.ds {
echo("DROP TABLE IF EXISTS #arguments.prefix#roles");
echo("CREATE INDEX idx_#arguments.prefix#_users_role_id ON #arguments.prefix#users(role_id)");
}
}

if ( arguments.onlyDrop )
return;

query datasource=arguments.ds {
echo("CREATE TABLE #arguments.prefix#roles (
role_id INT,
role_name VARCHAR(100) DEFAULT NULL,
CONSTRAINT PK_#arguments.prefix#roles PRIMARY KEY ( role_id )
)");
}
query datasource=arguments.ds {
echo("CREATE TABLE #arguments.prefix#users (
user_id VARCHAR(50) NOT NULL,
user_name VARCHAR(50) NOT NULL,
role_id INT DEFAULT NULL,
CONSTRAINT PK_#arguments.prefix#users PRIMARY KEY ( user_id )
)");
}
query datasource=arguments.ds {
echo("ALTER TABLE #arguments.prefix#users
ADD CONSTRAINT fk_#arguments.prefix#_user_role_id
FOREIGN KEY (role_id)
REFERENCES #arguments.prefix#roles ( role_id )");
}
query datasource=arguments.ds {
echo("CREATE INDEX idx_#arguments.prefix#_users_role_id ON #arguments.prefix#users(role_id)");
}

query datasource=arguments.ds {
echo("CREATE VIEW #arguments.prefix#v_users AS
SELECT u.user_id, u.user_name, r.role_id, r.role_name
FROM #arguments.prefix#users u, #arguments.prefix#roles r
WHERE r.role_id = u.role_id
");
query datasource=arguments.ds {
echo("CREATE VIEW #arguments.prefix#v_users AS
SELECT u.user_id, u.user_name, r.role_id, r.role_name
FROM #arguments.prefix#users u, #arguments.prefix#roles r
WHERE r.role_id = u.role_id
");
}
} catch (any e){
systemOutput( "Error creating schema for #arguments.dbtype#: #e.message#", true );
rethrow;
}
/*
query name="local.tables" params={ table: arguments.prefix & "%" } datasource=arguments.ds {
Expand Down

0 comments on commit 9f0ef41

Please sign in to comment.