diff --git a/.gitignore b/.gitignore
index 5c99b4d..5b832af 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
.gradle
.idea
+.intellijPlatform
.qodana
build
.DS_Store
diff --git a/.run/Run IDE for UI Tests.run.xml b/.run/Run IDE for UI Tests.run.xml
deleted file mode 100644
index ee99b7e..0000000
--- a/.run/Run IDE for UI Tests.run.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
- false
-
-
-
\ No newline at end of file
diff --git a/.run/Run Qodana.run.xml b/.run/Run Qodana.run.xml
deleted file mode 100644
index c92f33c..0000000
--- a/.run/Run Qodana.run.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
- false
-
-
-
\ No newline at end of file
diff --git a/.run/Run Tests.run.xml b/.run/Run Tests.run.xml
index 132d9ad..f281bdc 100644
--- a/.run/Run Tests.run.xml
+++ b/.run/Run Tests.run.xml
@@ -19,6 +19,7 @@
true
true
false
+ true
diff --git a/.run/Run Verifications.run.xml b/.run/Run Verifications.run.xml
index 3a8d688..32783f5 100644
--- a/.run/Run Verifications.run.xml
+++ b/.run/Run Verifications.run.xml
@@ -11,7 +11,7 @@
-
+
@@ -19,8 +19,7 @@
true
true
false
-
-
-
+ false
+
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f0f20c4..6c10990 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,17 @@
## [Unreleased]
+## [1.2.9] - 2024-08-22
+
+### Fixed
+
+- Fixed unsigned data type
+- Supoort goframe WhereBuilder
+
+### Changed
+
+- upgrade libraries
+
## [1.2.8] - 2023-12-29
### Fixed
diff --git a/README-ja_JP.md b/README-ja_JP.md
index 697d842..a909e8e 100644
--- a/README-ja_JP.md
+++ b/README-ja_JP.md
@@ -51,4 +51,8 @@
### ローカルインストール
- 【Go ORMアシスタント】プラグインパッケージのダウンロード [Releases](https://github.com/maiqingqiang/go-orm-helper/releases)
-- プラグイン・チュートリアルのインストール https://www.jetbrains.com/help/idea/managing-plugins.html
\ No newline at end of file
+- プラグイン・チュートリアルのインストール https://www.jetbrains.com/help/idea/managing-plugins.html
+
+## Star History
+
+[](https://star-history.com/#maiqingqiang/go-orm-helper&Date)
\ No newline at end of file
diff --git a/README-ko_KR.md b/README-ko_KR.md
index c1fbc76..79b58c7 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -51,4 +51,8 @@
### 로컬 설치
- [Go ORM 도우미] 플러그인 패키지 다운로드 [Releases](https://github.com/maiqingqiang/go-orm-helper/releases)
-- 플러그인 설치 자습서 https://www.jetbrains.com/help/idea/managing-plugins.html
\ No newline at end of file
+- 플러그인 설치 자습서 https://www.jetbrains.com/help/idea/managing-plugins.html
+
+## Star History
+
+[](https://star-history.com/#maiqingqiang/go-orm-helper&Date)
\ No newline at end of file
diff --git a/README-zh_CN.md b/README-zh_CN.md
index 78e7e50..35269a4 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -73,4 +73,8 @@ https://www.jetbrains.com/help/go/auto-completing-code.html#code-completion-for-
### 本地安装
- 下载【Go ORM 助手】插件包 [Releases](https://github.com/maiqingqiang/go-orm-helper/releases)
-- 安装插件教程: https://www.jetbrains.com/help/idea/managing-plugins.html
\ No newline at end of file
+- 安装插件教程: https://www.jetbrains.com/help/idea/managing-plugins.html
+
+## Star History
+
+[](https://star-history.com/#maiqingqiang/go-orm-helper&Date)
\ No newline at end of file
diff --git a/README.md b/README.md
index 934d162..44e7044 100644
--- a/README.md
+++ b/README.md
@@ -74,3 +74,7 @@ Selected SQL -> Editor Popup Menu -> Go ORM Helper Tool -> SQL Convert Struct
- Download Go ORM Helper Plugin [Releases](https://github.com/maiqingqiang/go-orm-helper/releases)
- Install plugins guide: https://www.jetbrains.com/help/idea/managing-plugins.html
+
+## Star History
+
+[](https://star-history.com/#maiqingqiang/go-orm-helper&Date)
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 82ceed2..659b530 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,97 +1,76 @@
import org.jetbrains.changelog.Changelog
-
-fun properties(key: String) = providers.gradleProperty(key)
-fun environment(key: String) = providers.environmentVariable(key)
+import org.jetbrains.changelog.markdownToHTML
+import org.jetbrains.intellij.platform.gradle.TestFrameworkType
plugins {
id("java") // Java support
alias(libs.plugins.kotlin) // Kotlin support
- alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
+ alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
}
-group = properties("pluginGroup").get()
-version = properties("pluginVersion").get()
+group = providers.gradleProperty("pluginGroup").get()
+version = providers.gradleProperty("pluginVersion").get()
+
+// Set the JVM language level used to build the project.
+kotlin {
+ jvmToolchain(17)
+}
// Configure project's dependencies
repositories {
mavenCentral()
+
+ // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
+ intellijPlatform {
+ defaultRepositories()
+ }
}
// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
-// implementation(libs.annotations)
implementation(libs.guava)
implementation(libs.druid)
implementation(libs.jsqlparser)
implementation(libs.evoInflector)
+ implementation(libs.annotations)
+
compileOnly(libs.lombok)
annotationProcessor(libs.lombok)
-}
-// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
-kotlin {
- @Suppress("UnstableApiUsage")
- jvmToolchain {
- languageVersion = JavaLanguageVersion.of(17)
- vendor = JvmVendorSpec.JETBRAINS
- }
-}
+ testImplementation(libs.junit)
-// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
-intellij {
- pluginName = properties("pluginName")
- version = properties("platformVersion")
- type = properties("platformType")
+ // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
+ intellijPlatform {
+ create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))
- // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
- plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }
+ // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
+ bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
- updateSinceUntilBuild = false
-}
+ // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
+ plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })
-// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
-changelog {
- groups.empty()
- repositoryUrl = properties("pluginRepositoryUrl")
-}
-
-// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
-qodana {
- cachePath = provider { file(".qodana").canonicalPath }
- reportPath = provider { file("build/reports/inspections").canonicalPath }
- saveReport = true
- showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false)
-}
-
-// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
-koverReport {
- defaults {
- xml {
- onCheck = true
- }
+ instrumentationTools()
+ pluginVerifier()
+ zipSigner()
+ testFramework(TestFrameworkType.Platform)
}
}
-tasks {
- wrapper {
- gradleVersion = properties("gradleVersion").get()
- }
-
- patchPluginXml {
- version = properties("pluginVersion")
- sinceBuild = properties("pluginSinceBuild")
- untilBuild = properties("pluginUntilBuild")
+// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
+intellijPlatform {
+ pluginConfiguration {
+ version = providers.gradleProperty("pluginVersion")
// Extract the section from README.md and provide for the plugin's manifest
- pluginDescription = projectDir.resolve("DESCRIPTION.md").readText()
+ description = projectDir.resolve("DESCRIPTION.md").readText()
val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
- changeNotes = properties("pluginVersion").map { pluginVersion ->
+ changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
@@ -101,30 +80,78 @@ tasks {
)
}
}
- }
- // Configure UI tests plugin
- // Read more: https://github.com/JetBrains/intellij-ui-test-robot
- runIdeForUiTests {
- systemProperty("robot-server.port", "8082")
- systemProperty("ide.mac.message.dialogs.as.sheets", "false")
- systemProperty("jb.privacy.policy.text", "")
- systemProperty("jb.consents.confirmation.enabled", "false")
+ ideaVersion {
+ sinceBuild = providers.gradleProperty("pluginSinceBuild")
+ untilBuild = providers.gradleProperty("pluginUntilBuild")
+ }
}
- signPlugin {
- certificateChainFile = File(environment("CERTIFICATE_CHAIN_FILE").get())
- privateKeyFile = File(environment("PRIVATE_KEY_FILE").get())
- password = environment("PRIVATE_KEY_PASSWORD")
+ signing {
+ certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN")
+ privateKey = providers.environmentVariable("PRIVATE_KEY")
+ password = providers.environmentVariable("PRIVATE_KEY_PASSWORD")
}
- publishPlugin {
- dependsOn("patchChangelog")
- token = environment("JETBRAINS_PUBLISH_TOKEN")
+ publishing {
+ token = providers.environmentVariable("PUBLISH_TOKEN")
// The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
- channels =
- properties("pluginVersion").map { listOf(it.split('-').getOrElse(1) { "default" }.split('.').first()) }
+ channels = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) }
+ }
+
+ pluginVerification {
+ ides {
+ recommended()
+ }
+ }
+}
+
+// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
+changelog {
+ groups.empty()
+ repositoryUrl = providers.gradleProperty("pluginRepositoryUrl")
+}
+
+// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
+kover {
+ reports {
+ total {
+ xml {
+ onCheck = true
+ }
+ }
+ }
+}
+
+tasks {
+ wrapper {
+ gradleVersion = providers.gradleProperty("gradleVersion").get()
+ }
+
+ publishPlugin {
+ dependsOn(patchChangelog)
+ }
+}
+
+intellijPlatformTesting {
+ runIde {
+ register("runIdeForUiTests") {
+ task {
+ jvmArgumentProviders += CommandLineArgumentProvider {
+ listOf(
+ "-Drobot-server.port=8082",
+ "-Dide.mac.message.dialogs.as.sheets=false",
+ "-Djb.privacy.policy.text=",
+ "-Djb.consents.confirmation.enabled=false",
+ )
+ }
+ }
+
+ plugins {
+ robotServerPlugin()
+ }
+ }
}
}
diff --git a/gradle.properties b/gradle.properties
index 84c22a5..1152aa5 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -4,22 +4,24 @@ pluginGroup = com.github.maiqingqiang.goormhelper
pluginName = Go ORM Helper
pluginRepositoryUrl = https://github.com/maiqingqiang/go-orm-helper
# SemVer format -> https://semver.org
-pluginVersion = 1.2.8
+pluginVersion = 1.2.9
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
-pluginSinceBuild = 222
-#pluginUntilBuild = 232.*
+pluginSinceBuild = 232
+#pluginUntilBuild = 242.*
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = GO
-platformVersion = 2022.2.5
+platformVersion = 2023.2.7
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
-# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
-platformPlugins = org.jetbrains.plugins.go
+# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP
+platformPlugins =
+# Example: platformBundledPlugins = com.intellij.java
+platformBundledPlugins = org.jetbrains.plugins.go
# Gradle Releases -> https://github.com/gradle/gradle/releases
-gradleVersion = 8.5
+gradleVersion = 8.10
# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
kotlin.stdlib.default.dependency = false
@@ -30,8 +32,5 @@ org.gradle.configuration-cache = true
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.caching = true
-# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
-systemProp.org.gradle.unsafe.kotlin.assignment = true
-
org.gradle.parallel = true
org.gradle.jvmargs = '-Dfile.encoding=UTF-8'
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 52fc133..0fe104f 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,31 +1,33 @@
[versions]
# libraries
-annotations = "24.1.0"
-lombok = "1.18.30"
-guava = "33.0.0-jre"
-druid = "1.2.20"
-jsqlparser = "4.8"
+junit = "5.11.0"
+lombok = "1.18.34"
+guava = "33.3.0-jre"
+druid = "1.2.23"
+jsqlparser = "5.0"
evoInflector = "1.3"
-
+annotations = "24.1.0"
# plugins
-kotlin = "1.9.21"
-changelog = "2.2.0"
-gradleIntelliJPlugin = "1.16.1"
-qodana = "0.1.13"
-kover = "0.7.5"
+changelog = "2.2.1"
+intelliJPlatform = "2.0.1"
+kotlin = "1.9.25"
+kover = "0.8.3"
+qodana = "2024.1.9"
[libraries]
-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
+junit = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
lombok = { group = "org.projectlombok", name = "lombok", version.ref = "lombok" }
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
druid = { group = "com.alibaba", name = "druid", version.ref = "druid" }
jsqlparser = { group = "com.github.jsqlparser", name = "jsqlparser", version.ref = "jsqlparser" }
evoInflector = { group = "org.atteo", name = "evo-inflector", version.ref = "evoInflector" }
+annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
+
[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
-gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" }
+intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index d64cd49..2c35211 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 1af9e09..9355b41 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
index 1aa94a4..f5feea6 100755
--- a/gradlew
+++ b/gradlew
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
diff --git a/gradlew.bat b/gradlew.bat
index 93e3f59..9d21a21 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 9b0179d..b6484c2 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,5 +1 @@
-plugins {
- id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
-}
-
rootProject.name = "Go ORM Helper"
diff --git a/src/main/java/com/github/maiqingqiang/goormhelper/services/GoORMHelperCacheManager.java b/src/main/java/com/github/maiqingqiang/goormhelper/services/GoORMHelperCacheManager.java
index 6cea860..a3b3862 100644
--- a/src/main/java/com/github/maiqingqiang/goormhelper/services/GoORMHelperCacheManager.java
+++ b/src/main/java/com/github/maiqingqiang/goormhelper/services/GoORMHelperCacheManager.java
@@ -115,7 +115,7 @@ public void scanProject(@NotNull VirtualFile root, List excluded) {
if (!fileOrDir.isDirectory()) {
ScannedPath scanned = state.scannedPathMapping.get(fileOrDir.getUrl());
if (scanned == null || scanned.getLastModified() != fileOrDir.getTimeStamp()) {
- parseGoFile(fileOrDir);
+ fileOrDir.refresh(true, true, () -> parseGoFile(fileOrDir));
}
}
return true;
diff --git a/src/main/java/com/github/maiqingqiang/goormhelper/sql2struct/impl/SQL2Struct.java b/src/main/java/com/github/maiqingqiang/goormhelper/sql2struct/impl/SQL2Struct.java
index f404ee4..fa59ab3 100644
--- a/src/main/java/com/github/maiqingqiang/goormhelper/sql2struct/impl/SQL2Struct.java
+++ b/src/main/java/com/github/maiqingqiang/goormhelper/sql2struct/impl/SQL2Struct.java
@@ -2,6 +2,7 @@
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.SQLUtils;
+import com.alibaba.druid.sql.ast.SQLDataTypeImpl;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
@@ -19,9 +20,9 @@ public class SQL2Struct implements ISQL2Struct {
Map.entry("numeric", "int32"),
Map.entry("integer", "int32"),
Map.entry("int", "int32"),
- Map.entry("smallint", "int32"),
+ Map.entry("tinyint", "int8"),
+ Map.entry("smallint", "int16"),
Map.entry("mediumint", "int32"),
- Map.entry("tinyint", "int32"),
Map.entry("bigint", "int64"),
Map.entry("float", "float32"),
Map.entry("real", "float64"),
@@ -45,11 +46,21 @@ public class SQL2Struct implements ISQL2Struct {
Map.entry("date", "time.Time"),
Map.entry("datetime", "time.Time"),
Map.entry("timestamp", "time.Time"),
- Map.entry("year", "int32"),
+ Map.entry("year", "uint16"),
Map.entry("bit", "[]uint8"),
Map.entry("boolean", "bool")
);
+
+ private static final Map unsignedDataType = Map.ofEntries(
+ Map.entry("tinyint", "uint8"),
+ Map.entry("smallint", "uint16"),
+ Map.entry("mediumint", "uint32"),
+ Map.entry("int", "uint32"),
+ Map.entry("bigint", "uint64")
+ );
+
private static final String defaultDataType = "string";
+ private static final String defaultUnsignedDataType = "uint32";
private final String sql;
private final DbType dbType;
@@ -92,13 +103,11 @@ private void singleConvert(@NotNull StringBuilder stringBuilder, SQLStatement st
stringBuilder.append("}\n\n");
}
- private String getGoType(String type) {
- System.out.println("type -> "+type);
- return dataType.getOrDefault(type.toLowerCase(), defaultDataType);
- }
-
protected String getGoType(@NotNull SQLColumnDefinition definition) {
- return getGoType(definition.getDataType().getName());
+ String typeName = definition.getDataType().getName().toLowerCase();
+ boolean isUnsigned = ((SQLDataTypeImpl) definition.getDataType()).isUnsigned();
+
+ return isUnsigned ? unsignedDataType.getOrDefault(typeName, defaultUnsignedDataType) : dataType.getOrDefault(typeName, defaultDataType);
}
protected void generateStructField(@NotNull StringBuilder stringBuilder, @NotNull SQLColumnDefinition definition) {