Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow multi-line string literals #19164

Merged
merged 12 commits into from
Oct 5, 2019

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ StringCharacters

fragment
StringCharacter
: ~["\\]
: ~["\\\u000A\u000D]
| EscapeSequence
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function main() {
// statement execution is successful, the `update` remote function
// returns 0.
io:println("The update operation - Creating a table:");
var ret = testDB->update("CREATE TABLE student(id INT AUTO_INCREMENT,
age INT, name VARCHAR(255), PRIMARY KEY (id))");
var ret = testDB->update("CREATE TABLE student(id INT AUTO_INCREMENT, " +
"age INT, name VARCHAR(255), PRIMARY KEY (id))");
handleUpdate(ret, "Create student table");

json jsonMsg = {
Expand Down Expand Up @@ -65,8 +65,8 @@ public function main() {
// A batch of data can be inserted using the `batchUpdate` remote function.
// The number of inserted rows for each insert in the batch is returned as
// an array.
jdbc:BatchUpdateResult retBatch = testDB->batchUpdate("INSERT INTO student
(age,name) VALUES (?,?)", false, ...dataBatch);
jdbc:BatchUpdateResult retBatch = testDB->batchUpdate("INSERT INTO student " +
"(age,name) VALUES (?,?)", false, ...dataBatch);
error? e = retBatch.returnedError;
if (e is error) {
io:println("Batch update operation failed:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ public function main() {
// statement execution is successful, the `update` remote function
// returns 0.
io:println("The update operation - Creating table and procedures:");
var ret = testDB->update("CREATE TABLE student(id INT AUTO_INCREMENT,
age INT, name VARCHAR(255), PRIMARY KEY (id))");
var ret = testDB->update("CREATE TABLE student(id INT AUTO_INCREMENT, " +
"age INT, name VARCHAR(255), PRIMARY KEY (id))");
handleUpdate(ret, "Create student table");

// Create the stored procedure with IN parameters.
ret = testDB->update("CREATE PROCEDURE INSERTDATA(IN pAge INT,
IN pName VARCHAR(255))
BEGIN
INSERT INTO student(age, name) values (pAge, pName);
END");
ret = testDB->update("CREATE PROCEDURE INSERTDATA(IN pAge INT, " +
"IN pName VARCHAR(255)) " +
"BEGIN " +
"INSERT INTO student(age, name) values (pAge, pName); " +
"END");
handleUpdate(ret, "Stored procedure with IN param creation");

// Create the stored procedure with INOUT and OUT parameters.
ret = testDB->update("CREATE PROCEDURE GETCOUNT (INOUT pID INT,
OUT pCount INT)
BEGIN
SELECT id INTO pID FROM student WHERE age = pID;
SELECT COUNT(*) INTO pCount FROM student
WHERE age = 20;
END");
ret = testDB->update("CREATE PROCEDURE GETCOUNT (INOUT pID INT, " +
"OUT pCount INT) " +
"BEGIN " +
"SELECT id INTO pID FROM student WHERE age = pID; " +
"SELECT COUNT(*) INTO pCount FROM student " +
"WHERE age = 20; " +
"END");
handleUpdate(ret, "Stored procedure with INOUT/OUT param creation");


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public function main() {
// statement execution is successful, the `update` remote function
// returns 0.
io:println("The update operation - Creating a table");
var ret = testDB->update("CREATE TABLE student(id INT AUTO_INCREMENT,
age INT, name VARCHAR(255), PRIMARY KEY (id))");
var ret = testDB->update("CREATE TABLE student(id INT AUTO_INCREMENT, " +
"age INT, name VARCHAR(255), PRIMARY KEY (id))");
handleUpdate(ret, "Create student table");

// Insert data to the table using the `update` remote function. If the DML
// statement execution is successful, the `update` remote function returns
// the updated row count. The query parameters are given in the query
// statement itself.
io:println("\nThe update operation - Inserting data to a table");
ret = testDB->update("INSERT INTO student(age, name) values
(23, 'john')");
ret = testDB->update("INSERT INTO student(age, name) values " +
"(23, 'john')");
handleUpdate(ret, "Insert to student table with no parameters");

// The query parameters are given as variables for the `update` remote
Expand Down Expand Up @@ -77,8 +77,8 @@ public function main() {
io:println("\nThe Update operation - Inserting data");
age = 31;
name = "Kate";
var retWithKey = testDB->update("INSERT INTO student
(age, name) values (?, ?)", age, name);
var retWithKey = testDB->update("INSERT INTO student " +
"(age, name) values (?, ?)", age, name);
if (retWithKey is jdbc:UpdateResult) {
int count = retWithKey.updatedRowCount;
int generatedKey = <int>retWithKey.generatedKeys["GENERATED_KEY"];
Expand Down
4 changes: 2 additions & 2 deletions examples/jdbc-streaming-big-dataset/big_data_service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ service dataService on new http:Listener(9090) {
// Set a payload indicating an error in case the data retrieval
// fails.
res.statusCode = http:STATUS_INTERNAL_SERVER_ERROR;
res.setPayload({ "Error": "Error occured while retrieving data
from the database" });
res.setPayload({ "Error": "Error occured while retrieving data " +
"from the database" });
}

// Respond to the client.
Expand Down
38 changes: 19 additions & 19 deletions examples/jdbc-streaming-big-dataset/data_setup.bal
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ public function main() {
});

// Create a table for data insertion.
var ret = testDB->update("CREATE TABLE Data (id INT, field1
VARCHAR(1024), field2 VARCHAR(1024));");
var ret = testDB->update("CREATE TABLE Data (id INT, field1 " +
"VARCHAR(1024), field2 VARCHAR(1024));");
handleUpdate(ret, "Create Data table");

// Create the stored procedure with row_count IN parameter.
ret = testDB->update("CREATE PROCEDURE PopulateData(IN row_count INT)
BEGIN
DECLARE count INT;
DECLARE strDataEntry VARCHAR(1024);
SET count = 1;
SET strDataEntry = '';
WHILE count <= 1024 DO
SET strDataEntry = CONCAT(strDataEntry, 'x');
SET count = count + 1;
END WHILE;
SET count = 1;
WHILE count <= row_count DO
INSERT INTO Data VALUES (count, strDataEntry, strDataEntry);
SET count = count + 1;
END WHILE;
SELECT strDataEntry;
END");
ret = testDB->update("CREATE PROCEDURE PopulateData(IN row_count INT) " +
"BEGIN " +
"DECLARE count INT; " +
"DECLARE strDataEntry VARCHAR(1024); " +
"SET count = 1; " +
"SET strDataEntry = ''; " +
"WHILE count <= 1024 DO " +
"SET strDataEntry = CONCAT(strDataEntry, 'x'); " +
"SET count = count + 1; " +
"END WHILE; " +
"SET count = 1; " +
"WHILE count <= row_count DO " +
"INSERT INTO Data VALUES (count, strDataEntry, strDataEntry); " +
"SET count = count + 1; " +
"END WHILE; " +
"SELECT strDataEntry; " +
"END");
handleUpdate(ret, "Stored procedure with IN param creation");

// Call stored procedure. This inserts around 200MB of textual data.
Expand Down
12 changes: 6 additions & 6 deletions examples/local-transactions/local_transactions.bal
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jdbc:Client testDB = new ({

public function main() {
// Creates the tables that are required for the transaction.
var ret = testDB->update("CREATE TABLE CUSTOMER (ID INTEGER, NAME
VARCHAR(30))");
var ret = testDB->update("CREATE TABLE CUSTOMER (ID INTEGER, NAME " +
"VARCHAR(30))");
handleUpdate(ret, "Create CUSTOMER table");

ret = testDB->update("CREATE TABLE SALARY (ID INTEGER, MON_SALARY FLOAT)");
Expand All @@ -28,11 +28,11 @@ public function main() {
// aborting it. Only integer literals or constants are allowed as the `retry count`.
transaction with retries = 4 {
// This is the first remote function participant of the transaction.
ret = testDB->update("INSERT INTO CUSTOMER(ID,NAME)
VALUES (1, 'Anne')");
ret = testDB->update("INSERT INTO CUSTOMER(ID,NAME) " +
"VALUES (1, 'Anne')");
// This is the second remote function participant of the transaction.
ret = testDB->update("INSERT INTO SALARY (ID, MON_SALARY)
VALUES (1, 2500)");
ret = testDB->update("INSERT INTO SALARY (ID, MON_SALARY) " +
"VALUES (1, 2500)");
if (ret is jdbc:UpdateResult) {
io:println("Inserted count: ", ret.updatedRowCount);
// If the transaction is forced to abort, it will roll back the transaction
Expand Down
12 changes: 6 additions & 6 deletions examples/rabbitmq-producer/rabbitmq_producer.bal
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function main() {
worker w1 {
var sendResult = newChannel1->basicPublish("Hello from Ballerina", "MyQueue1");
if (sendResult is error) {
io:println("An error occurred while sending the message to
MyQueue1 using newChannel1.");
io:println("An error occurred while sending the message to " +
"MyQueue1 using newChannel1.");
}
}

Expand All @@ -36,8 +36,8 @@ public function main() {
worker w2 {
var sendResult = newChannel2->basicPublish("Hello from Ballerina", "MyQueue1");
if (sendResult is error) {
io:println("An error occurred while sending the message to
MyQueue1 using newChannel2.");
io:println("An error occurred while sending the message to " +
"MyQueue1 using newChannel2.");
}
}

Expand All @@ -46,8 +46,8 @@ public function main() {
worker w3 {
var sendResult = newChannel1->basicPublish("Hello from Ballerina", "MyQueue2");
if (sendResult is error) {
io:println("An error occurred while sending the message to
MyQueue2 using newChannel1.");
io:println("An error occurred while sending the message to " +
"MyQueue2 using newChannel1.");
}
}
_ = wait {w1, w2, w3};
Expand Down
4 changes: 2 additions & 2 deletions examples/request-with-multiparts/request_with_multiparts.bal
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ service multipartDemoService on new http:Listener(9090) {
}
} else {
http:Response response = new;
response.setPayload("Error occurred while sending multipart
request!");
response.setPayload("Error occurred while sending multipart " +
"request!");
response.statusCode = 500;
var result = caller->respond(response);
if (result is error) {
Expand Down
22 changes: 11 additions & 11 deletions examples/table-queries/table_queries.bal
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ public function main() {
tempOrderTable.items as items,
tempOrderTable.amount as amount;
queryStmt = "\ntable<OrderDetails> orderDetailsTable = " +
"from personTable as tempPersonTable
join orderTable as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId
select tempOrderTable.orderId as orderId, " +
"from personTable as tempPersonTable " +
"join orderTable as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId " +
"select tempOrderTable.orderId as orderId, " +
"tempPersonTable.name as personName, " +
"tempOrderTable.items as items, " +
"tempOrderTable.amount as amount;";
Expand All @@ -143,13 +143,13 @@ public function main() {
tempOrderTable.items as items,
tempOrderTable.amount as amount;
queryStmt = "\ntable<OrderDetails> orderDetailsWithFilter = " +
"from personTable where name != 'jane' as tempPersonTable
join orderTable where personId != 3 as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId
select tempOrderTable.orderId as orderId, " +
"tempPersonTable.name as personName," +
"tempOrderTable.items as items,
tempOrderTable.amount as amount;";
"from personTable where name != 'jane' as tempPersonTable " +
"join orderTable where personId != 3 as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId " +
"select tempOrderTable.orderId as orderId, " +
"tempPersonTable.name as personName, " +
"tempOrderTable.items as items, " +
"tempOrderTable.amount as amount;";
printTable(queryStmt, "orderDetailsWithFilter: ", orderDetailsWithFilter);
}

Expand Down
7 changes: 3 additions & 4 deletions examples/transactions-distributed/participant.bal
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ service ParticipantService on new http:Listener(8889) {
var updateReq = <@untainted> req.getJsonPayload();
if (updateReq is json) {
string msg =
io:sprintf("Update stock quote request received.
symbol:%s, price:%s",
updateReq.symbol,
updateReq.price);
io:sprintf("Update stock quote request received. " +
"symbol:%s, price:%s",
updateReq.symbol, updateReq.price);
log:printInfo(msg);

json jsonRes = { "message": "updating stock" };
Expand Down
8 changes: 4 additions & 4 deletions examples/xa-transactions/xa_transactions.bal
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jdbc:Client testDB2 = new({

public function main() {
// Creates the table named CUSTOMER in the first database.
var ret = testDB1->update("CREATE TABLE CUSTOMER (ID INTEGER
AUTO_INCREMENT, NAME VARCHAR(30))");
var ret = testDB1->update("CREATE TABLE CUSTOMER (ID INTEGER " +
"AUTO_INCREMENT, NAME VARCHAR(30))");
handleUpdate(ret, "Create CUSTOMER table");
// Creates the table named SALARY in the second database.
ret = testDB2->update("CREATE TABLE SALARY (ID INT, VALUE FLOAT)");
Expand All @@ -32,8 +32,8 @@ public function main() {
transaction {
// This is the first remote function to participate in the transaction. It inserts
// the customer name to the first DB and gets the generated key.
var result = testDB1->update("INSERT INTO CUSTOMER(NAME)
VALUES ('Anne')");
var result = testDB1->update("INSERT INTO CUSTOMER(NAME) " +
"VALUES ('Anne')");
int key = -1;
if (result is jdbc:UpdateResult) {
int count = result.updatedRowCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ public function main() {
tempOrderTable.amount as amount;

queryStmt = "\ntable<OrderDetails> orderDetailsTable = " +
"from personTable as tempPersonTable
join orderTable as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId
select tempOrderTable.orderId as orderId, " +
"from personTable as tempPersonTable " +
"join orderTable as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId " +
"select tempOrderTable.orderId as orderId, " +
"tempPersonTable.name as personName, " +
"tempOrderTable.items as items, " +
"tempOrderTable.amount as amount;";
Expand All @@ -191,13 +191,13 @@ public function main() {
tempOrderTable.amount as amount;

queryStmt = "\ntable<OrderDetails> orderDetailsWithFilter = " +
"from personTable where name != 'jane' as tempPersonTable
join orderTable where personId != 3 as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId
select tempOrderTable.orderId as orderId, " +
"from personTable where name != 'jane' as tempPersonTable " +
"join orderTable where personId != 3 as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId " +
"select tempOrderTable.orderId as orderId," +
"tempPersonTable.name as personName," +
"tempOrderTable.items as items,
tempOrderTable.amount as amount;";
"tempOrderTable.items as items," +
"tempOrderTable.amount as amount;";

printTable(queryStmt, "orderDetailsWithFilter: ", orderDetailsWithFilter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ public function main() {
tempOrderTable.amount as amount;

queryStmt = "\ntable<OrderDetails> orderDetailsTable = " +
"from personTable as tempPersonTable
join orderTable as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId
select tempOrderTable.orderId as orderId, " +
"from personTable as tempPersonTable " +
"join orderTable as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId " +
"select tempOrderTable.orderId as orderId, " +
"tempPersonTable.name as personName, " +
"tempOrderTable.items as items, " +
"tempOrderTable.amount as amount;";
Expand All @@ -160,13 +160,13 @@ public function main() {
tempOrderTable.amount as amount;

queryStmt = "\ntable<OrderDetails> orderDetailsWithFilter = " +
"from personTable where name != 'jane' as tempPersonTable
join orderTable where personId != 3 as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId
select tempOrderTable.orderId as orderId, " +
"from personTable where name != 'jane' as tempPersonTable " +
"join orderTable where personId != 3 as tempOrderTable " +
"on tempPersonTable.id == tempOrderTable.personId " +
"select tempOrderTable.orderId as orderId," +
"tempPersonTable.name as personName," +
"tempOrderTable.items as items,
tempOrderTable.amount as amount;";
"tempOrderTable.items as items," +
"tempOrderTable.amount as amount;";

printTable(queryStmt, "orderDetailsWithFilter: ", orderDetailsWithFilter);
}
Expand Down
4 changes: 2 additions & 2 deletions stdlib/jdbc/src/main/ballerina/src/java.jdbc/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ The CREATE statement is executed via the `update` remote function of the client.

```ballerina
// Create the ‘Students’ table with fields ‘id’, 'name' and ‘age’.
var returned = testDB->update("CREATE TABLE student(id INT AUTO_INCREMENT, age INT,
name VARCHAR(255), PRIMARY KEY (id))");
var returned = testDB->update("CREATE TABLE student(id INT AUTO_INCREMENT, age INT, " +
"name VARCHAR(255), PRIMARY KEY (id))");
if (returned is jdbc:UpdateResult) {
io:println("Students table create status in DB: ", returned.updatedRowCount);
} else {
Expand Down
Loading