JetBrains / exposed-intellij-plugin

Exposed Kotlin ORM framework gradle and intellij plugins
Apache License 2.0
40 stars 12 forks source link

Gradle Plugin: Not generating DAO Tables w/ H2 backend #18

Open kewilson opened 1 year ago

kewilson commented 1 year ago

Not sure what I have wrong here but would appreciate some guidance.

I push table definitions to a local H2 db using Liquibase via build.gradle.kts, the tables are verified as present in the db using DataGrip plugin in Intellij. I then issue the generateExposedCode task which runs but generates only a single empty GeneratedTables.kt class file.

Below are the relevant bits of config:

build.gradle.kts:

liquibase {
    activities.register("main") {
        this.arguments = mapOf(
            "logLevel" to "debug",
            "changelogFile" to "src/main/resources/migrations.sql",
            "url" to "jdbc:h2:./test;MODE=PostgreSQL;SCHEMA=public;DEFAULT_NULL_ORDERING=HIGH;CASE_INSENSITIVE_IDENTIFIERS=TRUE",
            "username" to "sa",
            "password" to "sa",
            "defaultSchemaName" to "public"
        )
    }
    runList = "main"
}

exposedCodeGeneratorConfig {
    propertiesFilename = "exposed.properties"
}

exposed.properties file:

generateSingleFile=false
packageName=com.myapp.exposed
databaseDriver=org.h2.Driver
#databaseName=
user=sa
password=sa
connectionURL=jdbc:h2:./test;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE

Below is a snippet of the log generated where you'll see it finds the schemas but there isn't anything shown for table count, etc. other than it saying it processed zero tables.

2023-06-01T16:20:29.884-0500 [DEBUG] [org.gradle.api.internal.tasks.execution.TaskExecution] Executing actions for task ':generateExposedCode'.
2023-06-01T16:20:29.884-0500 [INFO] [schemacrawler.tools.databaseconnector.DatabaseConnectionSource] Making connection to jdbc:h2:./test;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE
for user 'sa', with properties {}
2023-06-01T16:20:29.888-0500 [INFO] [schemacrawler.tools.databaseconnector.DatabaseConnectionSource] Opened database connection <conn5: url=jdbc:h2:./test user=SA>
2023-06-01T16:20:29.889-0500 [INFO] [schemacrawler.crawl.RetrieverConnection] Supported table types are <[table, view, external, system table, table link]>
2023-06-01T16:20:29.889-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running none
2023-06-01T16:20:29.889-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running crawlDatabaseInfo
2023-06-01T16:20:29.889-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveDatabaseInfo
2023-06-01T16:20:29.889-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveJdbcDriverInfo
2023-06-01T16:20:29.889-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveCrawlInfo
2023-06-01T16:20:29.889-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveAdditionalDatabaseInfo
2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveServerInfo
2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.DatabaseInfoRetriever] Not retrieving server information, since this was not requested
2023-06-01T16:20:29.895-0500 [DEBUG] [schemacrawler.crawl.DatabaseInfoRetriever] Server information SQL statement was not provided
2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveDatabaseUsers
2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.DatabaseInfoRetriever] Not retrieving database users information, since this was not requested
2023-06-01T16:20:29.895-0500 [DEBUG] [schemacrawler.crawl.DatabaseInfoRetriever] Database users SQL statement was not provided
2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveAdditionalJdbcDriverInfo
2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running none
2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Total time taken for <none> - 00:00:00.000 hours

2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.SchemaCrawler] 
-- generated by: SchemaCrawler 16.15.7
-- generated on: 2023-06-01T21:20:29.890693
-- database: H2 1.4.199 (2019-03-13)
-- driver: H2 JDBC Driver 1.4.199 (2019-03-13)
-- operating system: Mac OS X 11.1
-- JVM system: Eclipse Adoptium OpenJDK 64-Bit Server VM 17+35

2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running crawlSchemas
2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveSchemas
2023-06-01T16:20:29.895-0500 [DEBUG] [schemacrawler.crawl.SchemaRetriever] Schemata SQL statement was not provided
2023-06-01T16:20:29.895-0500 [INFO] [schemacrawler.crawl.SchemaRetriever] Retrieving all schemas
2023-06-01T16:20:29.896-0500 [INFO] [schemacrawler.crawl.SchemaRetriever] Retrieving all catalogs
2023-06-01T16:20:29.896-0500 [INFO] [schemacrawler.crawl.SchemaRetriever] Processed 1 catalogs
2023-06-01T16:20:29.896-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Crawling result set
2023-06-01T16:20:29.896-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Total time taken for <crawlResultSet> - 00:00:00.000 hours
-  0.0% - 00:00:00.000 - <retrieveResults>

2023-06-01T16:20:29.896-0500 [INFO] [schemacrawler.crawl.MetadataResultSet] Processed 2 rows for <retrieveAllSchemas>
2023-06-01T16:20:29.896-0500 [INFO] [schemacrawler.crawl.SchemaRetriever] Processed 2 schemas
2023-06-01T16:20:29.896-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running filterAndSortSchemas
2023-06-01T16:20:29.896-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running none
2023-06-01T16:20:29.896-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Total time taken for <none> - 00:00:00.000 hours

2023-06-01T16:20:29.897-0500 [INFO] [schemacrawler.crawl.SchemaCrawler] Retrieved 2 schemas
2023-06-01T16:20:29.897-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running crawlColumnDataTypes
2023-06-01T16:20:29.897-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveColumnDataTypes
2023-06-01T16:20:29.897-0500 [INFO] [schemacrawler.crawl.DataTypeRetriever] Retrieving system column data types
2023-06-01T16:20:29.897-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Crawling result set
2023-06-01T16:20:29.897-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Total time taken for <crawlResultSet> - 00:00:00.000 hours
-  0.0% - 00:00:00.000 - <retrieveResults>

2023-06-01T16:20:29.899-0500 [INFO] [schemacrawler.crawl.DataTypeRetriever] Processed 44 system column data types
2023-06-01T16:20:29.900-0500 [INFO] [schemacrawler.crawl.MetadataResultSet] Processed 44 rows for <retrieveSystemColumnDataTypesFromDataDictionary>
2023-06-01T16:20:29.900-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveUserDefinedColumnDataTypes
2023-06-01T16:20:29.900-0500 [INFO] [schemacrawler.crawl.DataTypeRetriever] Retrieving user-defined data types for schema <test.information_schema>
2023-06-01T16:20:29.900-0500 [INFO] [schemacrawler.crawl.DataTypeRetriever] Retrieving data types for schema <test.information_schema>
2023-06-01T16:20:29.900-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Crawling result set
2023-06-01T16:20:29.900-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Total time taken for <crawlResultSet> - 00:00:00.000 hours
-  0.0% - 00:00:00.000 - <retrieveResults>

2023-06-01T16:20:29.900-0500 [INFO] [schemacrawler.crawl.DataTypeRetriever] Retrieving user-defined data types for schema <test.public>
2023-06-01T16:20:29.900-0500 [INFO] [schemacrawler.crawl.DataTypeRetriever] Retrieving data types for schema <test.public>
2023-06-01T16:20:29.901-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Crawling result set
2023-06-01T16:20:29.901-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Total time taken for <crawlResultSet> - 00:00:00.000 hours
-  0.0% - 00:00:00.000 - <retrieveResults>

2023-06-01T16:20:29.901-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running none
2023-06-01T16:20:29.901-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Total time taken for <none> - 00:00:00.000 hours

2023-06-01T16:20:29.901-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running crawlTables
2023-06-01T16:20:29.901-0500 [INFO] [schemacrawler.crawl.RetrievalStopWatch] Running retrieveTables
2023-06-01T16:20:29.901-0500 [INFO] [schemacrawler.crawl.SchemaCrawler] Retrieving table names
2023-06-01T16:20:29.901-0500 [INFO] [schemacrawler.crawl.TableRetriever] Retrieving tables
2023-06-01T16:20:29.901-0500 [INFO] [schemacrawler.crawl.TableRetriever] Retrieving tables for schema <test.information_schema>
2023-06-01T16:20:29.902-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Crawling result set
2023-06-01T16:20:29.902-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Total time taken for <crawlResultSet> - 00:00:00.000 hours
-  0.0% - 00:00:00.000 - <retrieveResults>

2023-06-01T16:20:29.903-0500 [INFO] [schemacrawler.crawl.TableRetriever] Processed 0 tables
2023-06-01T16:20:29.903-0500 [INFO] [schemacrawler.crawl.MetadataResultSet] Processed 0 rows for <retrieveTablesFromMetadata>
2023-06-01T16:20:29.903-0500 [INFO] [schemacrawler.crawl.TableRetriever] Retrieving tables for schema <test.public>
2023-06-01T16:20:29.903-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Crawling result set
2023-06-01T16:20:29.904-0500 [DEBUG] [schemacrawler.crawl.ResultsCrawler] Total time taken for <crawlResultSet> - 00:00:00.000 hours
-  0.0% - 00:00:00.000 - <retrieveResults>

2023-06-01T16:20:29.904-0500 [INFO] [schemacrawler.crawl.TableRetriever] Processed 0 tables
2023-06-01T16:20:29.904-0500 [INFO] [schemacrawler.crawl.MetadataResultSet] Processed 0 rows for <retrieveTablesFromMetadata>
2023-06-01T16:20:29.904-0500 [INFO] [schemacrawler.crawl.SchemaCrawler] Retrieved 0 tables
kewilson commented 1 year ago

I switched to using a postgres server instead of H2 and the table generation does occur but it doesn't respect the generateSingleFile=false directive and throws and error (below). Going to play around with this a bit to see if I can't get the classes I need but looks like this plugin could use some attention.

2023-06-02T10:53:58.313-0500 [DEBUG] [schemacrawler.crawl.DatabaseInfoRetriever] Could not execute method <public abstract java.sql.RowIdLifetime java.sql.DatabaseMetaData.getRowIdLifetime() throws java.sql.SQLException>
java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc.PgDatabaseMetaData.getRowIdLifetime() is not yet implemented.
        at org.postgresql.Driver.notImplemented(Driver.java:699)
gabrielbunselmeyer commented 1 year ago

looks like this plugin could use some attention.

Just want to +1 this. The generation is pretty broken when using the time libraries as well.