Steve
Steve

Reputation: 53

How can I have slick generates query without double quotes?

I'm trying to using Slick to interact with Oracle DB. The mapping is:

trait EntityTable extends DataBaseConfig{

  import driver.api._

  class Log(tag: Tag) extends Table[LogEntity](tag,"LOG_SCHEMA.A_TABLE_WITH_VERY_LONG_NAME") {
    def id = column[Option[Long]]("LOG_ID",O.PrimaryKey,O.AutoInc)
    def log = column[String]("LOG_TEXT")

    def * = (LOG_ID, LOG_TEXT) <> ((LogEntity.apply _).tupled, LogEntity.unapply)
  }
  protected val getLogs = TableQuery[Log]
}

From the debugger I see the SQL generated is:

select "LOG_ID", "LOG_TEXT" from "LOG_SCHEMA.A_TABLE_WITH_VERY_LONG_NAME"

This gives me an

ORA-00972: identifier is too long

How can I have slick generates query without double quotes? Or is there a better way to deal with long table name in different schemes which I do not have control over? Thanks!

Upvotes: 2

Views: 623

Answers (1)

Sergiu Velescu
Sergiu Velescu

Reputation: 514

In Oracle you can not have names (table, index, view) longer than 30 characters. In your example I guess you have a mistake, instead of

"LOG_SCHEMA.A_TABLE_WITH_VERY_LONG_NAME"

try this:

"""LOG_SCHEMA"."A_TABLE_WITH_VERY_LONG_NAME"""

or this:

"\"LOG_SCHEMA\".\"A_TABLE_WITH_VERY_LONG_NAME\""

It does not matter how the table has been created A_TABLE_WITH_VERY_LONG_NAME can not have more than 30 characters.

Upvotes: 1

Related Questions