Menu

StringValue and escape

2008-06-27
2012-12-07
  • Patrick Dowler

    Patrick Dowler - 2008-06-27

    In some code, I am trying to construct a new StringValue, eg

      StringValue sv = new StringValue("abcd");

    When I write out the results (via SelectDeparser or just looking at the value returned from sv.getValue() or sv.getNonEscapedValue() the first and last letters are missing. Is this thing parsing a string literal? That is, do I need to include single or double quote characters, in addition to the string, eg

      StringValue sv = new StringValue("'abcd'");

    This works, but I want to know if it is on purpose or if I am not understanding it as it doesn't quite make sense to me.

    thanks,

    Patrick

     
    • Leonardo Francalanci

      Yes, that's how is supposed to work: the parser calls the constructor with the "escapedValue":

      public StringValue(String escapedValue)

      so it calls it with, say, "'mystring'"

       

Log in to post a comment.