{"action":"created","issue":{"url":"https://api.github.com/repos/jOOQ/jOOQ/issues/8720","repository_url":"https://api.github.com/repos/jOOQ/jOOQ","labels_url":"https://api.github.com/repos/jOOQ/jOOQ/issues/8720/labels{/name}","comments_url":"https://api.github.com/repos/jOOQ/jOOQ/issues/8720/comments","events_url":"https://api.github.com/repos/jOOQ/jOOQ/issues/8720/events","html_url":"https://github.com/jOOQ/jOOQ/issues/8720","id":450564788,"node_id":"MDU6SXNzdWU0NTA1NjQ3ODg=","number":8720,"title":"jOOQ parser could be more flexible","user":{"login":"rsmckinney","id":588843,"node_id":"MDQ6VXNlcjU4ODg0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/588843?v=4","gravatar_id":"","url":"https://api.github.com/users/rsmckinney","html_url":"https://github.com/rsmckinney","followers_url":"https://api.github.com/users/rsmckinney/followers","following_url":"https://api.github.com/users/rsmckinney/following{/other_user}","gists_url":"https://api.github.com/users/rsmckinney/gists{/gist_id}","starred_url":"https://api.github.com/users/rsmckinney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsmckinney/subscriptions","organizations_url":"https://api.github.com/users/rsmckinney/orgs","repos_url":"https://api.github.com/users/rsmckinney/repos","events_url":"https://api.github.com/users/rsmckinney/events{/privacy}","received_events_url":"https://api.github.com/users/rsmckinney/received_events","type":"User","site_admin":false},"labels":[{"id":1374045379,"node_id":"MDU6TGFiZWwxMzc0MDQ1Mzc5","url":"https://api.github.com/repos/jOOQ/jOOQ/labels/C:%20Parser","name":"C: Parser","color":"0000aa","default":false},{"id":1031730499,"node_id":"MDU6TGFiZWwxMDMxNzMwNDk5","url":"https://api.github.com/repos/jOOQ/jOOQ/labels/E:%20All%20Editions","name":"E: All Editions","color":"ffff00","default":false},{"id":9935166,"node_id":"MDU6TGFiZWw5OTM1MTY2","url":"https://api.github.com/repos/jOOQ/jOOQ/labels/P:%20Medium","name":"P: Medium","color":"ffaaaa","default":false},{"id":9935174,"node_id":"MDU6TGFiZWw5OTM1MTc0","url":"https://api.github.com/repos/jOOQ/jOOQ/labels/R:%20Duplicate","name":"R: Duplicate","color":"bbffbb","default":false},{"id":9935128,"node_id":"MDU6TGFiZWw5OTM1MTI4","url":"https://api.github.com/repos/jOOQ/jOOQ/labels/T:%20Enhancement","name":"T: Enhancement","color":"cccccc","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/jOOQ/jOOQ/milestones/152","html_url":"https://github.com/jOOQ/jOOQ/milestone/152","labels_url":"https://api.github.com/repos/jOOQ/jOOQ/milestones/152/labels","id":2832459,"node_id":"MDk6TWlsZXN0b25lMjgzMjQ1OQ==","number":152,"title":"Version 3.12.0","description":"","creator":{"login":"lukaseder","id":734593,"node_id":"MDQ6VXNlcjczNDU5Mw==","avatar_url":"https://avatars2.githubusercontent.com/u/734593?v=4","gravatar_id":"","url":"https://api.github.com/users/lukaseder","html_url":"https://github.com/lukaseder","followers_url":"https://api.github.com/users/lukaseder/followers","following_url":"https://api.github.com/users/lukaseder/following{/other_user}","gists_url":"https://api.github.com/users/lukaseder/gists{/gist_id}","starred_url":"https://api.github.com/users/lukaseder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukaseder/subscriptions","organizations_url":"https://api.github.com/users/lukaseder/orgs","repos_url":"https://api.github.com/users/lukaseder/repos","events_url":"https://api.github.com/users/lukaseder/events{/privacy}","received_events_url":"https://api.github.com/users/lukaseder/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":895,"state":"closed","created_at":"2017-10-12T08:16:15Z","updated_at":"2019-08-29T13:44:51Z","due_on":null,"closed_at":"2019-08-29T13:44:51Z"},"comments":35,"created_at":"2019-05-31T00:39:58Z","updated_at":"2019-08-30T05:13:38Z","closed_at":"2019-05-31T07:17:34Z","author_association":"NONE","body":"### Use case:\r\nI'm use the jOOQ parser as a general SQL parser, both for schema parsing and query parsing.  I find the parser unsuitable for this use-case, or perhaps I'm missing something.  For instance, parsing schema via `Parser#parse(schema)` return a `Queries`.  Internally I see all the information I need e.g., a list of `QueryTableImpl` with field `columnFields`, however access to this information is private.  I'd rather not resort to reflection.  I can see the `accept(ctx)` method, where I could in theory visit each column field, but that is abusing the API, not to mention the inherent inefficiency.\r\n\r\nAlso missing from the API is token information for declared elements.  Many tools, for example, require the location of the declared table name as well as the column names.  For instance, the name offsets enable my tool to navigate to/from SQL table & column names corresponding with Java class & property declarations within an IDE.\r\n\r\n>Note the same requirements apply to Select queries e.g., need name offsets to each field in the select list.\r\n\r\n### Possible solution you'd like to see:\r\nProvide methods for immutable access to the column fields.  And retain token offsets or line/column information for table and column API classes.\r\n\r\nPlease describe a possible solution you'd like to see in jOOQ, ideally with example code.\r\nAdd the Interface:\r\n```java\r\ninterface CreateTable {\r\n  Iterable<TableField> getColumnFields();\r\n  String getName();\r\n}\r\n```\r\n\r\nAlso add the method to `QueryPart`:.\r\n```java\r\nint getNameOffset();\r\n```\r\nand/or:\r\n```java\r\nIterable<Token> getTokens();\r\n```\r\n\r\n### Possible workarounds:\r\nUse reflection to get `columnFields`.  No workaround for name offset.\r\n\r\n### Versions:\r\n- jOOQ: 3.11.11"},"comment":{"url":"https://api.github.com/repos/jOOQ/jOOQ/issues/comments/526458125","html_url":"https://github.com/jOOQ/jOOQ/issues/8720#issuecomment-526458125","issue_url":"https://api.github.com/repos/jOOQ/jOOQ/issues/8720","id":526458125,"node_id":"MDEyOklzc3VlQ29tbWVudDUyNjQ1ODEyNQ==","user":{"login":"rsmckinney","id":588843,"node_id":"MDQ6VXNlcjU4ODg0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/588843?v=4","gravatar_id":"","url":"https://api.github.com/users/rsmckinney","html_url":"https://github.com/rsmckinney","followers_url":"https://api.github.com/users/rsmckinney/followers","following_url":"https://api.github.com/users/rsmckinney/following{/other_user}","gists_url":"https://api.github.com/users/rsmckinney/gists{/gist_id}","starred_url":"https://api.github.com/users/rsmckinney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsmckinney/subscriptions","organizations_url":"https://api.github.com/users/rsmckinney/orgs","repos_url":"https://api.github.com/users/rsmckinney/repos","events_url":"https://api.github.com/users/rsmckinney/events{/privacy}","received_events_url":"https://api.github.com/users/rsmckinney/received_events","type":"User","site_admin":false},"created_at":"2019-08-30T05:13:38Z","updated_at":"2019-08-30T05:13:38Z","author_association":"NONE","body":"I have it hooked up and getting errors on simple DDL.  I've tried several different simple schemas, same exact error.\r\n\r\n## Exception:\r\n```\r\nError:java: org.jooq.exception.DataAccessException: SQL [set catalog world]; Syntax error in SQL statement \"SET CATALOG[*] WORLD \"; expected \"@, AUTOCOMMIT, MVCC, EXCLUSIVE, IGNORECASE, PASSWORD, SALT, MODE, COMPRESS_LOB, DATABASE, COLLATION, BINARY_COLLATION, UUID_COLLATION, CLUSTER, DATABASE_EVENT_LISTENER, ALLOW_LITERALS, DEFAULT_TABLE_TYPE, CREATE, HSQLDB.DEFAULT_TABLE_TYPE, PAGE_STORE, CACHE_TYPE, FILE_LOCK, DB_CLOSE_ON_EXIT, AUTO_SERVER, AUTO_SERVER_PORT, AUTO_RECONNECT, ASSERT, ACCESS_MODE_DATA, OPEN_NEW, JMX, PAGE_SIZE, RECOVER, NAMES, SCOPE_GENERATED_KEYS, SCHEMA, DATESTYLE, SEARCH_PATH, SCHEMA_SEARCH_PATH, JAVA_OBJECT_SERIALIZER, LOGSIZE, FOREIGN_KEY_CHECKS\"; SQL statement:\r\n```\r\n\r\n## Stack Trace:\r\n```\r\nInformation:java: set catalog world [42001-199]\r\nInformation:java: \tat org.jooq_3.12.0.H2.debug(Unknown Source)\r\nInformation:java: \tat org.jooq.impl.Tools.translate(Tools.java:2717)\r\nInformation:java: \tat org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:755)\r\nInformation:java: \tat org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:383)\r\nInformation:java: \tat org.jooq.impl.DDLDatabaseInitializer.loadScript(DDLDatabaseInitializer.java:179)\r\nInformation:java: \tat org.jooq.impl.DDLDatabaseInitializer.initializeUsing(DDLDatabaseInitializer.java:153)\r\nInformation:java: \tat org.jooq.impl.DDLMetaProvider.provide(DDLMetaProvider.java:69)\r\nInformation:java: \tat org.jooq.impl.DefaultDSLContext.meta(DefaultDSLContext.java:443)\r\nInformation:java: \tat manifold.sql.type.SqlModel.parse(SqlModel.java:98)\r\nInformation:java: \tat manifold.sql.type.SqlModel.init(SqlModel.java:72)\r\nInformation:java: \tat manifold.sql.type.SqlModel.<init>(SqlModel.java:65)\r\nInformation:java: \tat manifold.sql.type.SqlManifold.lambda$init$0(SqlManifold.java:34)\r\nInformation:java: \tat manifold.api.type.ResourceFileTypeManifold.lambda$buildFqnToModelCache$0(ResourceFileTypeManifold.java:98)\r\nInformation:java: \tat manifold.util.concurrent.LocklessLazyVar$1.init(LocklessLazyVar.java:90)\r\nInformation:java: \tat manifold.util.concurrent.LocklessLazyVar.get(LocklessLazyVar.java:40)\r\nInformation:java: \tat manifold.api.type.ResourceFileTypeManifold.contribute(ResourceFileTypeManifold.java:391)\r\nInformation:java: \tat manifold.internal.host.SimpleModule.compoundProduce(SimpleModule.java:166)\r\nInformation:java: \tat manifold.internal.host.SimpleModule.lambda$produceFile$0(SimpleModule.java:139)\r\nInformation:java: \tat manifold.internal.javac.SourceSupplier.getSource(SourceSupplier.java:50)\r\nInformation:java: \tat manifold.internal.javac.GeneratedJavaStubFileObject.lambda$new$0(GeneratedJavaStubFileObject.java:40)\r\nInformation:java: \tat manifold.internal.javac.GeneratedJavaStubFileObject.getCharContent(GeneratedJavaStubFileObject.java:96)\r\nInformation:java: \tat com.sun.tools.javac.main.JavaCompiler.complete(JavaCompiler.java:772)\r\nInformation:java: \tat com.sun.tools.javac.main.JavaCompiler$1.complete(JavaCompiler.java:312)\r\nInformation:java: \tat com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2535)\r\nInformation:java: \tat com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2442)\r\nInformation:java: \tat com.sun.tools.javac.jvm.ClassReader.access$000(ClassReader.java:76)\r\nInformation:java: \tat com.sun.tools.javac.jvm.ClassReader$1.complete(ClassReader.java:240)\r\nInformation:java: \tat com.sun.tools.javac.code.Symbol.complete(Symbol.java:574)\r\nInformation:java: \tat com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1037)\r\nInformation:java: \tat com.sun.tools.javac.jvm.ClassReader.loadClass(ClassReader.java:2623)\r\nInformation:java: \tat com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:1907)\r\nInformation:java: \tat com.sun.tools.javac.comp.Resolve.findGlobalType(Resolve.java:2007)\r\nInformation:java: \tat com.sun.tools.javac.comp.Resolve.findType(Resolve.java:2085)\r\nInformation:java: \tat com.sun.tools.javac.comp.Resolve.findIdent(Resolve.java:2110)\r\nInformation:java: \tat com.sun.tools.javac.comp.Resolve.resolveIdent(Resolve.java:2384)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:3170)\r\nInformation:java: \tat com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2011)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3250)\r\nInformation:java: \tat manifold.internal.javac.ManAttr_8.visitSelect(ManAttr_8.java:114)\r\nInformation:java: \tat com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.attribType(Attr.java:638)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.attribType(Attr.java:631)\r\nInformation:java: \tat com.sun.tools.javac.comp.MemberEnter.visitVarDef(MemberEnter.java:649)\r\nInformation:java: \tat com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)\r\nInformation:java: \tat com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:437)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1034)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.attribStat(Attr.java:645)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.attribStats(Attr.java:661)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1124)\r\nInformation:java: \tat com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1013)\r\nInformation:java: \tat manifold.internal.javac.ManAttr_8.visitMethodDef(ManAttr_8.java:141)\r\nInformation:java: \tat com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4364)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4272)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4201)\r\nInformation:java: \tat com.sun.tools.javac.comp.Attr.attrib(Attr.java:4176)\r\nInformation:java: \tat com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1248)\r\nInformation:java: \tat com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)\r\nInformation:java: \tat com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)\r\nInformation:java: \tat com.sun.tools.javac.main.Main.compile(Main.java:523)\r\nInformation:java: \tat com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)\r\nInformation:java: \tat com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)\r\nInformation:java: \tat org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:195)\r\nInformation:java: \tat org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:460)\r\nInformation:java: \tat org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:330)\r\nInformation:java: \tat org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:255)\r\nInformation:java: \tat org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:213)\r\nInformation:java: \tat org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1324)\r\nInformation:java: \tat org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1004)\r\nInformation:java: \tat org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1071)\r\nInformation:java: \tat org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:965)\r\nInformation:java: \tat org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:794)\r\nInformation:java: \tat org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:376)\r\nInformation:java: \tat org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)\r\nInformation:java: \tat org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:139)\r\nInformation:java: \tat org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:288)\r\nInformation:java: \tat org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:121)\r\nInformation:java: \tat org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:228)\r\nInformation:java: \tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\r\nInformation:java: \tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\r\nInformation:java: \tat java.lang.Thread.run(Thread.java:748)\r\nInformation:java: \tat org.h2.message.DbException.getJdbcSQLException(DbException.java:451)\r\nInformation:java: \tat org.h2.message.DbException.getJdbcSQLException(DbException.java:427)\r\nInformation:java: \tat org.h2.command.Parser.parseSet(Parser.java:6959)\r\nInformation:java: \tat org.h2.command.Parser.parsePrepared(Parser.java:923)\r\nInformation:java: \tat org.h2.command.Parser.parse(Parser.java:788)\r\nInformation:java: \tat org.h2.command.Parser.parse(Parser.java:764)\r\nInformation:java: \tat org.h2.command.Parser.prepareCommand(Parser.java:683)\r\nInformation:java: \tat org.h2.engine.Session.prepareLocal(Session.java:627)\r\nInformation:java: \tat org.h2.engine.Session.prepareCommand(Session.java:565)\r\nInformation:java: \tat org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1292)\r\nInformation:java: \tat org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:77)\r\nInformation:java: \tat org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:349)\r\nInformation:java: \tat org.jooq.impl.ProviderEnabledConnection.prepareStatement(ProviderEnabledConnection.java:109)\r\nInformation:java: \tat org.jooq.impl.SettingsEnabledConnection.prepareStatement(SettingsEnabledConnection.java:73)\r\nInformation:java: \tat org.jooq.impl.AbstractQuery.prepare(AbstractQuery.java:435)\r\nInformation:java: \tat org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:336)\r\nInformation:java: \t... 88 more\r\n```\r\n\r\n## Sample Schema:\r\n```sql\r\nCREATE SCHEMA world;\r\nUSE world;\r\n\r\nCREATE TABLE `city` (\r\n  `ID` INT(11) NOT NULL AUTO_INCREMENT,\r\n  `Name` CHAR(35) NOT NULL DEFAULT '',\r\n  `CountryCode` CHAR(3) NOT NULL DEFAULT '',\r\n  `District` CHAR(20) NOT NULL DEFAULT '',\r\n  `Population` INT(11) NOT NULL DEFAULT '0',\r\n  PRIMARY KEY (`ID`),\r\n  KEY `CountryCode` (`CountryCode`),\r\n  CONSTRAINT `city_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `country` (`Code`)\r\n);\r\n\r\nCREATE TABLE `country` (\r\n  `Code` CHAR(3) NOT NULL DEFAULT '',\r\n  `Name` CHAR(52) NOT NULL DEFAULT '',\r\n  `Continent` enum('Asia','Europe','NorthAmerica','Africa','Oceania','Antarctica','SouthAmerica') NOT NULL DEFAULT 'Asia',\r\n  `Region` CHAR(26) NOT NULL DEFAULT '',\r\n  `SurfaceArea` FLOAT(10,2) NOT NULL DEFAULT '0.00',\r\n  `IndepYear` SMALLINT(6) DEFAULT NULL,\r\n  `Population` INT(11) NOT NULL DEFAULT '0',\r\n  `LifeExpectancy` FLOAT(3,1) DEFAULT NULL,\r\n  `GNP` FLOAT(10,2) DEFAULT NULL,\r\n  `GNPOld` FLOAT(10,2) DEFAULT NULL,\r\n  `LocalName` CHAR(45) NOT NULL DEFAULT '',\r\n  `GovernmentForm` CHAR(45) NOT NULL DEFAULT '',\r\n  `HeadOfState` CHAR(60) DEFAULT NULL,\r\n  `Capital` INT(11) DEFAULT NULL,\r\n  `Code2` CHAR(2) NOT NULL DEFAULT '',\r\n  PRIMARY KEY (`Code`)\r\n);\r\n\r\nCREATE TABLE `countrylanguage` (\r\n  `CountryCode` CHAR(3) NOT NULL DEFAULT '',\r\n  `Language` CHAR(30) NOT NULL DEFAULT '',\r\n  `IsOfficial` enum('T','F') NOT NULL DEFAULT 'F',\r\n  `Percentage` FLOAT(4,1) NOT NULL DEFAULT '0.0',\r\n  PRIMARY KEY (`CountryCode`,`Language`),\r\n  KEY `CountryCode` (`CountryCode`),\r\n  CONSTRAINT `countryLanguage_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `country` (`Code`)\r\n);\r\n```"}}
{"actor":{"display_login":"rsmckinney"}}