Menu

#1588 At '@/' path dereferencing doesn't work in certain situations on Windows

version 2.5.x
open-fixed
None
5
2021-01-02
2020-08-02
Jesse Pavel
No

When running on Windows, @ dereferencing doesn't work when using paths with backslashes in sqltool command-lines, nor with the SqlFile constructions that accept File arguments.

For instance, for a script check-db-setup.sql that includes other scripts via \i @/other-script.sql, this constructor works,

new SqlFile(new URL("file", null, "sql/check-db-setup.sql"));

while this does not

new SqlFile(new File("sql/check-db-setup.sql"));

Discussion

  • Blaine Simpson

    Blaine Simpson - 2020-08-02

    Please confirm that the problem is with regular forward slashes within filepaths, not backslashes.

    Please paste the error message or indication.

     
  • Jesse Pavel

    Jesse Pavel - 2020-08-02

    When using the Java API, the problem occurs with forward slashes when using File constructors:

    Using this constructor for SqlFile
    SqlFile sqlFile = new SqlFile(new URL("file", null, "GPD/sql/check-db-setup.sql"));
    everything works fine with '@' dereferencing in check-db-setup.sql.

    When using this constructor:
    SqlFile sqlFile = new SqlFile(new File("GPD/sql/check-db-setup.sql"));
    one gets the error message below:

    SEVERE  Error at 'file:GPD\sql\check-db-setup.sql' line 7:
    "\i @/setup-sample-db.sql"
    Failed to execute contents of SQL file '@/setup-sample-db.sql'.
    SEVERE  Cause: FileNotFoundException: setup-sample-db.sql (The system cannot find the file specified)
    

    check-db-setup.sql and setup-sample-db.sql are in the same directory.

     
  • Jesse Pavel

    Jesse Pavel - 2020-08-03

    The attached patch, which normalizes backslashes to forward slashes in both this.atBase and passed paths, fixes the issue (at least for me...) with using new File() constructors, and also lets one use backslashes in SQL file paths on the sqltool commandline.

     
  • Blaine Simpson

    Blaine Simpson - 2020-08-03

    Ty. It will be some days until I'll be able to test this. In case I see different behavior, what JRE are you using?

     
  • Jesse Pavel

    Jesse Pavel - 2020-08-03

    The above behavior (and fix) occurs on Oracle Java 1.7.0_261, Zulu OpenJDK 1.8.0_252, and AdoptOpenJDK 14.0.2, all with Windows x64 arch.

     
  • Blaine Simpson

    Blaine Simpson - 2020-08-10

    Tested behavior. Ran SqlTool regression tests. Committed patch to base/trunk with rev. 6168.

    Thanks.

     
  • Fred Toussi

    Fred Toussi - 2021-01-02
    • status: open --> open-fixed
    • assigned_to: Blaine Simpson
     

Log in to post a comment.