Skip to content

Commit

Permalink
Fix name conflict/shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
Salvi committed Nov 6, 2019
1 parent f46a085 commit ce5d81e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
48 changes: 25 additions & 23 deletions src/main/kotlin/it/intre/code/database/reader/sql/SqlBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,40 @@ class SqlBuilder {
}

private fun _addCustomOrder(sql: String, queryProfile: QueryProfile): String {
var sql = sql
var sqlString = sql
if (queryProfile.isOrder) {
if (!sql.toLowerCase().contains("order by")) {
sql += " ORDER BY "
} else {
sql += ", "
}
sql += queryProfile.order
sqlString +=
if (!sqlString.toLowerCase().contains("order by")) {
" ORDER BY "
} else {
", "
}
sqlString += queryProfile.order
}
return sql
return sqlString
}

private fun _addCustomHaving(sql: String, queryProfile: QueryProfile): String {
var sql = sql
var sqlString = sql
if (queryProfile.isHaving) {
sql += " HAVING " + queryProfile.having
sqlString += " HAVING " + queryProfile.having
}
return sql
return sqlString
}

private fun _addCustomGroupBy(sql: String, groupBy: String, queryProfile: QueryProfile): String {
var sql = sql
sql += groupBy
var sqlString = sql
sqlString += groupBy
if (queryProfile.isGroup) {
if (groupBy.isEmpty()) {
sql += " GROUP BY "
} else {
sql += ","
}
sql += queryProfile.group
sqlString +=
if (groupBy.isEmpty()) {
" GROUP BY "
} else {
","
}
sqlString += queryProfile.group
}
return sql
return sqlString
}

private fun _addCustomWhere(sql: String, queryProfile: QueryProfile): String {
Expand All @@ -89,12 +91,12 @@ class SqlBuilder {
}

private fun _addMaxRecords(sql: String, queryProfile: QueryProfile): String {
var sql = sql
var sqlString = sql
if (queryProfile.isMaxRecords) {
//FIXME: depends on the driver - this implementation is valid for oracle 12c
sql += " OFFSET 0 ROWS FETCH NEXT ${queryProfile.maxRecords} ROWS ONLY"
sqlString += " OFFSET 0 ROWS FETCH NEXT ${queryProfile.maxRecords} ROWS ONLY"
}
return sql
return sqlString
}

internal fun setIsCount(isCount: Boolean?) {
Expand Down
14 changes: 7 additions & 7 deletions src/main/kotlin/it/intre/code/database/reader/sql/SqlHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ internal class SqlHelper private constructor() {

internal class Range(val from: Int, val to: Int) {

override fun equals(o: Any?): Boolean {
if (o === this) return true
if (o !is Range) return false
val other = o as Range?
if (!other!!.canEqual(this as Any)) return false
if (this.from != other.from) return false
return if (this.to != other.to) false else true
override fun equals(other: Any?): Boolean {
if (other === this) return true
if (other !is Range) return false
val range = other as Range?
if (!range!!.canEqual(this as Any)) return false
if (this.from != range.from) return false
return if (this.to != range.to) false else true
}

override fun hashCode(): Int {
Expand Down

0 comments on commit ce5d81e

Please sign in to comment.