Skip to content
Snippets Groups Projects
Commit e40ea874 authored by Volodymyr Lyubinets's avatar Volodymyr Lyubinets Committed by Aaron Davidson
Browse files

[Minor] [SQL] [SPARK-6729] Minor fix for DriverQuirks get

The function uses .substring(0, X), which will trigger OutOfBoundsException if string length is less than X. A better way to do this is to use startsWith, which won't error out in this case.

Author: Volodymyr Lyubinets <vlyubin@gmail.com>

Closes #5378 from vlyubin/quirks and squashes the following commits:

504e8e0 [Volodymyr Lyubinets] Minor fix for DriverQuirks get
parent 30363ede
No related branches found
No related tags found
No related merge requests found
...@@ -49,9 +49,9 @@ private[sql] object DriverQuirks { ...@@ -49,9 +49,9 @@ private[sql] object DriverQuirks {
* Fetch the DriverQuirks class corresponding to a given database url. * Fetch the DriverQuirks class corresponding to a given database url.
*/ */
def get(url: String): DriverQuirks = { def get(url: String): DriverQuirks = {
if (url.substring(0, 10).equals("jdbc:mysql")) { if (url.startsWith("jdbc:mysql")) {
new MySQLQuirks() new MySQLQuirks()
} else if (url.substring(0, 15).equals("jdbc:postgresql")) { } else if (url.startsWith("jdbc:postgresql")) {
new PostgresQuirks() new PostgresQuirks()
} else { } else {
new NoQuirks() new NoQuirks()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment