@Test public void testCanonicalizeStringAndRemoveWhitespaceEntirely() { List<String> testBatch = ImmutableList.of( "/* UnregisteredSQLString */ insert foo into bar; /* UnregisteredSQLString */insert foo into bar;", "insert foo into bar; /* UnregisteredSQLString */ insert foo into bar"); String canonicalBatch = "insertfoointobar;insertfoointobar"; testBatch.forEach(sql -> assertEquals(canonicalBatch, SQLString.canonicalizeStringAndRemoveWhitespaceEntirely(sql))); }
/** * A Factory used by the SQL class to turn a string sql query into an SQLString object. * This may just contain the sql given, or the given SQL may be overriden in the database and the object returned * will reflect that new SQL from the DB. * * @param sql The string to be used in a query * @return a SQLString object representing the given SQL */ @SuppressWarnings("GuardedByChecker") static FinalSQLString getUnregisteredQuery(String sql) { assert !isValidKey(sql) : "Unregistered Queries should not look like keys"; //$NON-NLS-1$ FinalSQLString cached = cachedUnregistered.get(canonicalizeStringAndRemoveWhitespaceEntirely(sql)); if (null != cached) { callbackOnUse.noteUse((SQLString) cached.delegate); return cached; } return new FinalSQLString(new SQLString(sql)); }
/** * A Factory used by the SQL class to turn a string sql query into an SQLString object. * This may just contain the sql given, or the given SQL may be overriden in the database and the object returned * will reflect that new SQL from the DB. * * @param sql The string to be used in a query * @return a SQLString object representing the given SQL */ @SuppressWarnings("GuardedByChecker") static FinalSQLString getUnregisteredQuery(String sql) { assert !isValidKey(sql) : "Unregistered Queries should not look like keys"; //$NON-NLS-1$ FinalSQLString cached = cachedUnregistered.get(canonicalizeStringAndRemoveWhitespaceEntirely(sql)); if (null != cached) { callbackOnUse.noteUse((SQLString) cached.delegate); return cached; } return new FinalSQLString(new SQLString(sql)); }