Escape quotes in string interpolation s“ALTER TABLE ${keyspace}.\”${tableName}\“”

情到浓时终转凉″ 提交于 2019-12-24 09:58:52

问题


In Scala, while querying Cassandra, this string interpolation

s"ALTER TABLE ${keyspace}.\"${tableName}\" "

gives me this error:

error: value $ is not a member of String [INFO] val query:String=s"ALTER TABLE ${keyspace}.\"${tableName}\" ADD $colName $dataTypeAsString;"

What am I doing wrong?


回答1:


The \" does not work inside string interpolations.

Try using strings delimited by triple quotes:

s"""ALTER TABLE ${keyspace}."${tableName}" """

or escape the inner double quotes by additional ${...}:

s"ALTER TABLE ${keyspace}.${'"'}${tableName}${'"'} "


来源:https://stackoverflow.com/questions/49987671/escape-quotes-in-string-interpolation-salter-table-keyspace-tablename

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!