-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
2654548
commit e5c8a89
Showing
10 changed files
with
156 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/net/sf/jsqlparser/statement/analyze/Analyze.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2022 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
package net.sf.jsqlparser.statement.analyze; | ||
|
||
import net.sf.jsqlparser.schema.Table; | ||
import net.sf.jsqlparser.statement.Statement; | ||
import net.sf.jsqlparser.statement.StatementVisitor; | ||
|
||
public class Analyze implements Statement { | ||
|
||
private Table table; | ||
|
||
@Override | ||
public void accept(StatementVisitor statementVisitor) { | ||
statementVisitor.visit(this); | ||
} | ||
|
||
public Table getTable() { | ||
return table; | ||
} | ||
|
||
public void setTable(Table table) { | ||
this.table = table; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ANALYZE " + table.toString(); | ||
} | ||
|
||
public Analyze withTable(Table table) { | ||
this.setTable(table); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/net/sf/jsqlparser/util/validation/validator/AnalyzeValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2022 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
package net.sf.jsqlparser.util.validation.validator; | ||
|
||
import net.sf.jsqlparser.parser.feature.Feature; | ||
import net.sf.jsqlparser.statement.analyze.Analyze; | ||
import net.sf.jsqlparser.util.validation.ValidationCapability; | ||
import net.sf.jsqlparser.util.validation.metadata.NamedObject; | ||
|
||
public class AnalyzeValidator extends AbstractValidator<Analyze>{ | ||
@Override | ||
public void validate(Analyze analyze) { | ||
for (ValidationCapability c : getCapabilities()) { | ||
validateFeature(c, Feature.analyze); | ||
validateName(c, NamedObject.table, analyze.getTable().getFullyQualifiedName(), true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/test/java/net/sf/jsqlparser/statement/analyze/AnalyzeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2022 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
package net.sf.jsqlparser.statement.analyze; | ||
|
||
import net.sf.jsqlparser.JSQLParserException; | ||
import net.sf.jsqlparser.parser.CCJSqlParserManager; | ||
import net.sf.jsqlparser.schema.Table; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.StringReader; | ||
|
||
import static net.sf.jsqlparser.test.TestUtils.assertDeparse; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class AnalyzeTest { | ||
|
||
private final CCJSqlParserManager parserManager = new CCJSqlParserManager(); | ||
|
||
@Test | ||
public void testAnalyze() throws JSQLParserException { | ||
String statement = "ANALYZE mytab"; | ||
Analyze parsed = (Analyze) parserManager.parse(new StringReader(statement)); | ||
assertEquals("mytab", parsed.getTable().getFullyQualifiedName()); | ||
assertEquals(statement, "" + parsed); | ||
|
||
assertDeparse(new Analyze().withTable(new Table("mytab")), statement); | ||
} | ||
|
||
} |