fix: Handle databases that do not support user-defined types
Add a null check to prevent NullPointerException when a database does not support user-defined data types.
This commit is contained in:
6
.idea/templateLanguages.xml
generated
Normal file
6
.idea/templateLanguages.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="TemplateDataLanguageMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources/templates/actionBean.ftl" dialect="JAVA" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Binary file not shown.
@@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.sdk.generators.actionmodels"
|
group = "com.sdk.generators.actionmodels"
|
||||||
version = "1.1.0"
|
version = "1.1.2"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -39,6 +39,15 @@ intellijPlatform {
|
|||||||
changeNotes = """
|
changeNotes = """
|
||||||
## Release Notes
|
## Release Notes
|
||||||
|
|
||||||
|
## [1.1.2]
|
||||||
|
fix: Update plugin version display
|
||||||
|
Corrected the plugin version display in the IDE.
|
||||||
|
|
||||||
|
## [1.1.1]
|
||||||
|
fix: Correctly generate primary keys
|
||||||
|
The generator was failing to identify primary key columns, resulting in generated beans without them. This has been fixed by updating the code to use the `getColumnsRef()` method, which correctly retrieves the column names for the primary key.
|
||||||
|
|
||||||
|
## [1.1.0]
|
||||||
### New Features and Enhancements
|
### New Features and Enhancements
|
||||||
|
|
||||||
* **DTO Generation:** Introduced new functionality to generate Data Transfer Object (DTO) classes alongside ActionBeans. This includes new FreeMarker templates (`actionDTO.ftl`, `actionDTO.extend.ftl`) and updated logic in `GeneratorServices.java`.
|
* **DTO Generation:** Introduced new functionality to generate Data Transfer Object (DTO) classes alongside ActionBeans. This includes new FreeMarker templates (`actionDTO.ftl`, `actionDTO.extend.ftl`) and updated logic in `GeneratorServices.java`.
|
||||||
@@ -49,7 +58,7 @@ intellijPlatform {
|
|||||||
* **Project Structure Refactoring:** The project structure has been reorganized. Generator-related classes were moved to a new package (`com.sdk.generators.actionmodels`), and template directory names were standardized to `src/main/resources/templates`.
|
* **Project Structure Refactoring:** The project structure has been reorganized. Generator-related classes were moved to a new package (`com.sdk.generators.actionmodels`), and template directory names were standardized to `src/main/resources/templates`.
|
||||||
* **Build System Updates:** Updated `build.gradle.kts`, `plugin.xml`, and Gradle wrapper files to reflect the structural and functional enhancements.
|
* **Build System Updates:** Updated `build.gradle.kts`, `plugin.xml`, and Gradle wrapper files to reflect the structural and functional enhancements.
|
||||||
|
|
||||||
""".trimIndent()
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.sdk.generators;
|
package com.sdk.generators;
|
||||||
|
|
||||||
import com.intellij.database.model.DasColumn;
|
import com.intellij.database.model.DasColumn;
|
||||||
|
import com.intellij.database.model.DasObject;
|
||||||
import com.intellij.database.model.ObjectKind;
|
import com.intellij.database.model.ObjectKind;
|
||||||
import com.intellij.database.psi.DbObject;
|
import com.intellij.database.psi.DbObject;
|
||||||
import com.intellij.database.psi.DbTable;
|
import com.intellij.database.psi.DbTable;
|
||||||
@@ -63,7 +64,9 @@ public class GUtils {
|
|||||||
|
|
||||||
public static void createUserDefineType(DbTable table) {
|
public static void createUserDefineType(DbTable table) {
|
||||||
String schemaName = table.getParent() != null ? table.getParent().getName() : "";
|
String schemaName = table.getParent() != null ? table.getParent().getName() : "";
|
||||||
DasUtil.getCatalogObject(table).getDasChildren(ObjectKind.SCHEMA).forEach(schema -> {
|
DasObject objCatalog = DasUtil.getCatalogObject(table);
|
||||||
|
if (objCatalog != null) {
|
||||||
|
objCatalog.getDasChildren(ObjectKind.SCHEMA).forEach(schema -> {
|
||||||
if (schema.getName().equals("public") || schema.getName().equals(schemaName)) {
|
if (schema.getName().equals("public") || schema.getName().equals(schemaName)) {
|
||||||
schema.getDasChildren(ObjectKind.OBJECT_TYPE).forEach(domain -> {
|
schema.getDasChildren(ObjectKind.OBJECT_TYPE).forEach(domain -> {
|
||||||
String domainName = domain.getName();
|
String domainName = domain.getName();
|
||||||
@@ -73,6 +76,7 @@ public class GUtils {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String getFieldType(DasColumn column) {
|
public static String getFieldType(DasColumn column) {
|
||||||
String columnType = column.getDasType().toDataType().typeName;
|
String columnType = column.getDasType().toDataType().typeName;
|
||||||
|
|||||||
@@ -10,6 +10,29 @@
|
|||||||
Right-click on a package and select "Generate Database Action Models" to start.
|
Right-click on a package and select "Generate Database Action Models" to start.
|
||||||
]]></description>
|
]]></description>
|
||||||
|
|
||||||
|
<change-notes><![CDATA[
|
||||||
|
## [1.1.2]
|
||||||
|
fix: Update plugin version display
|
||||||
|
Corrected the plugin version display in the IDE.
|
||||||
|
|
||||||
|
## [1.1.1]
|
||||||
|
fix: Correctly generate primary keys
|
||||||
|
The generator was failing to identify primary key columns, resulting in generated beans without them. This has been fixed by updating the code to use the `getColumnsRef()` method, which correctly retrieves the column names for the primary key.
|
||||||
|
|
||||||
|
## Release Notes
|
||||||
|
|
||||||
|
### New Features and Enhancements
|
||||||
|
|
||||||
|
* **DTO Generation:** Introduced new functionality to generate Data Transfer Object (DTO) classes alongside ActionBeans. This includes new FreeMarker templates (`actionDTO.ftl`, `actionDTO.extend.ftl`) and updated logic in `GeneratorServices.java`.
|
||||||
|
* **ActionField and DTOField Enhancements:** Implemented enhancements related to the generation of `ActionField` and `DTOField` within the generated classes.
|
||||||
|
|
||||||
|
### Refactoring and Improvements
|
||||||
|
|
||||||
|
* **Project Structure Refactoring:** The project structure has been reorganized. Generator-related classes were moved to a new package (`com.sdk.generators.actionmodels`), and template directory names were standardized to `src/main/resources/templates`.
|
||||||
|
* **Build System Updates:** Updated `build.gradle.kts`, `plugin.xml`, and Gradle wrapper files to reflect the structural and functional enhancements.
|
||||||
|
|
||||||
|
]]></change-notes>
|
||||||
|
|
||||||
<depends>com.intellij.modules.platform</depends>
|
<depends>com.intellij.modules.platform</depends>
|
||||||
<depends>com.intellij.modules.java</depends>
|
<depends>com.intellij.modules.java</depends>
|
||||||
<depends>com.intellij.database</depends>
|
<depends>com.intellij.database</depends>
|
||||||
|
|||||||
Reference in New Issue
Block a user