diff --git a/jooq-dialect/CHANGELOG.md b/jooq-dialect/CHANGELOG.md
new file mode 100644
index 0000000..efc0c6d
--- /dev/null
+++ b/jooq-dialect/CHANGELOG.md
@@ -0,0 +1,5 @@
+## 1.0.0 ##
+
+- `REPLACE` / `UPSERT` builders from YDB
+- Supported VIEW INDEX from `useIndex("index_name")` HintedTable
+- Generated tables from schema
diff --git a/jooq-dialect/pom.xml b/jooq-dialect/pom.xml
index 9b6403f..f297bb0 100644
--- a/jooq-dialect/pom.xml
+++ b/jooq-dialect/pom.xml
@@ -4,7 +4,7 @@
tech.ydb.dialects
jooq-ydb-dialect
- 1.0.0-RC1
+ 1.0.0
YDB JOOQ Dialect module
YDB JOOQ Dialect module
diff --git a/jooq-dialect/src/main/java/org/jooq/impl/YdbListener.java b/jooq-dialect/src/main/java/org/jooq/impl/YdbListener.java
new file mode 100644
index 0000000..4b0cf36
--- /dev/null
+++ b/jooq-dialect/src/main/java/org/jooq/impl/YdbListener.java
@@ -0,0 +1,76 @@
+package org.jooq.impl;
+
+import org.jooq.Name;
+import org.jooq.QueryPart;
+import org.jooq.RenderContext;
+import org.jooq.VisitContext;
+import org.jooq.VisitListener;
+
+/**
+ * @author Kirill Kurdyukov
+ */
+public class YdbListener implements VisitListener {
+
+ private final String quote;
+
+ private volatile int hintedTableStartSize;
+
+ public YdbListener(String quote) {
+ this.quote = quote;
+ }
+
+ @Override
+ public void visitStart(VisitContext context) {
+ addQuoteForName(context);
+ visitStartHint(context);
+ }
+
+ @Override
+ public void visitEnd(VisitContext context) {
+ addQuoteForName(context);
+ try {
+ visitEndHint(context);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void addQuoteForName(VisitContext context) {
+ QueryPart part = context.queryPart();
+ if (part instanceof Name) {
+ RenderContext renderContext = context.renderContext();
+ if (renderContext != null) {
+ renderContext.sql(quote);
+ }
+ }
+ }
+
+ private void visitStartHint(VisitContext context) {
+ QueryPart part = context.queryPart();
+
+ if (part instanceof QOM.HintedTable> hintedTable) {
+ if (context.renderContext() instanceof DefaultRenderContext renderContext) {
+ hintedTableStartSize = renderContext.sql.length();
+ }
+ }
+ }
+
+ private void visitEndHint(VisitContext context) throws NoSuchFieldException, IllegalAccessException {
+ QueryPart part = context.queryPart();
+
+ if (part instanceof HintedTable> hintedTable) {
+ if (context.renderContext() instanceof DefaultRenderContext renderContext) {
+ renderContext.sql.setLength(hintedTableStartSize);
+
+ renderContext.sql(" view ");
+
+ // Sorry, Lukas!!! :(
+ java.lang.reflect.Field fieldArguments = hintedTable.getClass().getDeclaredField("arguments");
+ fieldArguments.setAccessible(true);
+ QueryPartList arguments = (QueryPartList)fieldArguments.get(hintedTable);
+ renderContext.visit(arguments);
+ }
+ }
+ }
+}
+
diff --git a/jooq-dialect/src/main/java/tech/ydb/jooq/CustomQuoteListener.java b/jooq-dialect/src/main/java/tech/ydb/jooq/CustomQuoteListener.java
deleted file mode 100644
index 775c391..0000000
--- a/jooq-dialect/src/main/java/tech/ydb/jooq/CustomQuoteListener.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package tech.ydb.jooq;
-
-import org.jooq.Name;
-import org.jooq.QueryPart;
-import org.jooq.RenderContext;
-import org.jooq.VisitContext;
-import org.jooq.VisitListener;
-
-public class CustomQuoteListener implements VisitListener {
-
- private final String quote;
-
- public CustomQuoteListener(String quote) {
- this.quote = quote;
- }
-
- public CustomQuoteListener(char quote) {
- this.quote = String.valueOf(quote);
- }
-
- @Override
- public void visitStart(VisitContext context) {
- addQuoteForName(context);
- }
-
- @Override
- public void visitEnd(VisitContext context) {
- addQuoteForName(context);
- }
-
- private void addQuoteForName(VisitContext context) {
- QueryPart part = context.queryPart();
- if (part instanceof Name) {
- RenderContext renderContext = context.renderContext();
- if (renderContext != null) {
- renderContext.sql(quote);
- }
- }
- }
-}
-
diff --git a/jooq-dialect/src/main/java/tech/ydb/jooq/impl/YdbDSLContextImpl.java b/jooq-dialect/src/main/java/tech/ydb/jooq/impl/YdbDSLContextImpl.java
index 21e3311..b46a45e 100644
--- a/jooq-dialect/src/main/java/tech/ydb/jooq/impl/YdbDSLContextImpl.java
+++ b/jooq-dialect/src/main/java/tech/ydb/jooq/impl/YdbDSLContextImpl.java
@@ -68,7 +68,7 @@ public YdbDSLContextImpl(Configuration configuration) {
super(configuration
.deriveSettings(YdbDSLContextImpl::addRequiredParameters)
.set(YDB.DIALECT)
- .set(quoteListener()));
+ .set(ydbListener()));
}
private static Settings addRequiredParameters(Settings settings) {
@@ -77,8 +77,8 @@ private static Settings addRequiredParameters(Settings settings) {
.withRenderSchema(false);
}
- private static VisitListener quoteListener() {
- return new CustomQuoteListener("`");
+ private static VisitListener ydbListener() {
+ return new YdbListener("`");
}
@Override