playframework / playframework/playframework

Evolutions: Single semicolon—even in a comment—is treated as statement terminator

Open
#6,765 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
12.6k
Forks
4k
Avg merge
2d 3h
Merged PRs (30d)
29

Description

Double semicolon escapes are necessary in things like function bodies, but they are also needed in comments, which I believe is unintuitive. For example, if my evolution script were the following, I'd have a syntax error when running it:

CREATE TABLE foo(
  -- This is a test table; this line is erroneously treated as a syntax error because of the semicolon.
  id serial
);

The error that you get when running this is:

Database 'default' is in an inconsistent state!

We got the following error: ERROR: syntax error at end of input Position: 42 [ERROR:0, SQLSTATE:42601], while trying to run this SQL script:

1    # --- Rev:1,Ups - 15b2c43
2
3    CREATE TABLE foo(
4    -- This is a test table; this line is erroneously treated as a syntax error because of the semicolon.
5    id serial
6    );

Only by escaping the semicolon in the comment with a double semicolon (;;) does the script work. This can cause a lot of confusion—It took me an hour to find the cause in an 800-line evolution script—enough that it could be considered a bug.

Play Version (2.5.x / etc)

Play Version 2.5.3

API (Scala / Java / Neither / Both)

Scala

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

macOS Sierra (10.12.1)

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown evolution script, then trace the Play 2.5.3 evolution statement splitting around the comment containing a semicolon. Done means semicolons inside SQL comments no longer terminate the statement, with a regression test covering the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala, sql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.