Skip to content
Snippets Groups Projects
Commit 17b1a3b5 authored by npedot's avatar npedot
Browse files

removes ' from select attribute names

parent a57ba007
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ class SQLizeSelectUseCase {
fun sqlizeSelect(select : Select):String {
var sql = ""
sql += "SELECT " + select.attributes
.map { a -> "'${a.name}'" }.toList().joinToString(",") + System.lineSeparator()
.map { a -> "${a.name}" }.toList().joinToString(",") + System.lineSeparator()
sql += "FROM "
sql = sqlizeFrom(select, sql)
if (!select.where.condition.isEmpty()) {
......
......@@ -150,7 +150,7 @@ class MappingTest {
val actualSQL = SQLizeCreateUseCase().createViewCommand(mapping)
assertEquals("""
CREATE OR REPLACE VIEW public.query1 AS
SELECT 'student.first_name','student.last_name','course.name'
SELECT student.first_name,student.last_name,course.name
FROM student
JOIN student_course
ON student.id = student_course.student_id
......@@ -182,7 +182,7 @@ ON course.id = student_course.course_id
// then
assertEquals("""
CREATE OR REPLACE VIEW public.poid_ssn AS
SELECT 't1.ssn','t2.ssn'
SELECT t1.ssn,t2.ssn
FROM T AS t1
JOIN T AS t2
ON t1.ssn = t2.ssn2
......
......@@ -68,7 +68,7 @@ class QueryTest {
var querySql = SQLizeSelectUseCase().sqlize(query)
// then
assertEquals1("""
SELECT 'Name','Surname'
SELECT Name,Surname
FROM Table1
WHERE Name='Gigi' LIMIT 10
""".trimIndent(),querySql)
......@@ -90,7 +90,7 @@ class QueryTest {
val selectSql = SQLizeSelectUseCase().sqlizeSelect(select)
// then
assertEquals1("""
SELECT 'ww'
SELECT ww
FROM tab
WHERE a = b LIMIT 10
""".trimIndent(),selectSql)
......@@ -118,7 +118,7 @@ class QueryTest {
val selectSql = SQLizeSelectUseCase().sqlizeSelect(select)
// then
assertEquals1("""
SELECT 'ww'
SELECT ww
FROM Orders
INNER JOIN Customer
ON Orders.customerId = Customer.customerId
......@@ -155,7 +155,7 @@ class QueryTest {
val selectSql = SQLizeSelectUseCase().sqlizeSelect(select)
// then
assertEquals1("""
SELECT 'ww'
SELECT ww
FROM Orders
INNER JOIN Customer
ON Orders.customerId = Customer.customerId
......@@ -208,11 +208,11 @@ class QueryTest {
var querySql = SQLizeSelectUseCase().sqlize(query)
// then
assertEquals1("""
SELECT 'Name','Surname'
SELECT Name,Surname
FROM Table1
WHERE Name='Gigi' LIMIT 10
UNION
SELECT 'Name','Surname'
SELECT Name,Surname
FROM Table2
WHERE Name='Gigi' LIMIT 10
""".trimIndent(),querySql)
......@@ -315,15 +315,15 @@ class QueryTest {
val sqlize = SQLizeSelectUseCase().sqlize(query)
assertEquals("""
SELECT 'alfa','beta'
SELECT alfa,beta
FROM tab1
WHERE a = b LIMIT 10
UNION
SELECT 'gamma','theta'
SELECT gamma,theta
FROM tab2
WHERE c = d LIMIT 10
UNION
SELECT 'delta','zeta'
SELECT delta,zeta
FROM tab3
WHERE e = f LIMIT 10
""".trimIndent(),sqlize)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment