Open JakeR92 opened 2 months ago
Hi @JakeR92, can you please share a project that reproduce the issue?
/cc @inponomarev who has been contributing to this feature :)
Hi,
I have the following stored procedure in an sql file that is passed into the test container to be run upon startup. CREATE TABLE "Konnekt"."ProcedureVarChar" ( "primaryKey" VARCHAR2(255 CHAR) NOT NULL, "uniqueKey" VARCHAR2(255 CHAR) NOT NULL, "mandatory" VARCHAR2(255 CHAR) NOT NULL, "optional" VARCHAR2(255 CHAR), "defaultValue" VARCHAR2(255 CHAR) DEFAULT 'default' NOT NULL, PRIMARY KEY ("primaryKey"), UNIQUE ("uniqueKey") );
INSERT INTO "Konnekt"."ProcedureVarChar" ("primaryKey", "uniqueKey", "mandatory", "optional", "defaultValue") VALUES ('pk1', 'uq1', 'man', 'opt', 'Hello World'); INSERT INTO "Konnekt"."ProcedureVarChar" ("primaryKey", "uniqueKey", "mandatory", "optional") VALUES ('pk2', 'uq2', 'man', 'opt'); INSERT INTO "Konnekt"."ProcedureVarChar" ("primaryKey", "uniqueKey", "mandatory") VALUES ('pk3', 'uq3', 'man');
CREATE TABLE "Konnekt"."ProcedureVarCharBK" AS SELECT * FROM "Konnekt"."ProcedureVarChar";
CREATE OR REPLACE PROCEDURE "Konnekt"."insert_varchar_data"( p_primarykey VARCHAR2, p_unique VARCHAR2, p_mandatory VARCHAR2, p_optional VARCHAR2 DEFAULT NULL, p_default VARCHAR2 DEFAULT NULL ) IS BEGIN IF p_default IS NULL THEN INSERT INTO "Konnekt"."ProcedureVarChar" ("primaryKey", "uniqueKey", "mandatory", "optional") VALUES (p_primarykey, p_unique, p_mandatory, p_optional); ELSE INSERT INTO "Konnekt"."ProcedureVarChar" ("primaryKey", "uniqueKey", "mandatory", "optional", "defaultValue") VALUES (p_primarykey, p_unique, p_mandatory, p_optional, p_default); END IF; END;
Whenever I call the function it gets compile error. I debugged it and found that by the time the script runner runs the commands it is:
CREATE OR REPLACE PROCEDURE "Konnekt"."insert_varchar_data"( p_primarykey VARCHAR2, p_unique VARCHAR2, p_mandatory VARCHAR2, p_optional VARCHAR2 DEFAULT NULL, p_default VARCHAR2 DEFAULT NULL ) IS BEGIN IF p_default IS NULL THEN INSERT INTO "Konnekt"."ProcedureVarChar" ("primaryKey", "uniqueKey", "mandatory", "optional") VALUES (p_primarykey, p_unique, p_mandatory, p_optional); ELSE INSERT INTO "Konnekt"."ProcedureVarChar" ("primaryKey", "uniqueKey", "mandatory", "optional", "defaultValue") VALUES (p_primarykey, p_unique, p_mandatory, p_optional, p_default); END IF; END
Without the final ";". Oracle requires this final ";" otherwise it will not compile properly.
Any updates?
If the statement ends with ;; can we split by the last ; and keep the first ; as part of the statement?
Example: init.oracle.sql:
CREATE OR REPLACE PROCEDURE "sp_get_all_my_table"(total_count OUT INTEGER) AS
BEGIN
SELECT COUNT(*) INTO total_count FROM "MyTable";
END;;
Split by last ; and therefore, the statement will be:
CREATE OR REPLACE PROCEDURE "sp_get_all_my_table"(total_count OUT INTEGER) AS
BEGIN
SELECT COUNT(*) INTO total_count FROM "MyTable";
END;
Module
Core
Testcontainers version
1.19.8
Using the latest Testcontainers version?
Yes
Host OS
Linux
Host Arch
x86
Docker version
What happened?
The init script runner removes all ";" when splitting, however oracles stored procedure command requires the ";" at the end otherwise it gets a compile error. Can you change it not to remove the ";" from the split commands?
Relevant log output
No response
Additional Information
No response