Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value of 'now()' in date column causes error #329

Closed
jeenkhoorn opened this issue Dec 12, 2022 · 2 comments
Closed

Default value of 'now()' in date column causes error #329

jeenkhoorn opened this issue Dec 12, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@jeenkhoorn
Copy link

jeenkhoorn commented Dec 12, 2022

Describe the bug
In version 3.0.0 of Benerator CE the default value of 'now()' on a date column in a PostgreSQL will cause a crash while generating data for the table containing the column.

To Reproduce
Steps to reproduce the behavior:
Run Benerator for a table with a data column, non-nullable and with default value 'now()'.

You'll see the following error:

[ERROR] 2022-12-11 17:57:56.503 [main] Benerator - Error in Benerator execution
com.rapiddweller.common.ConversionException: Failed to convert now()
	at com.rapiddweller.common.exception.ExceptionFactory.conversionFailed(ExceptionFactory.java:163) ~[rd-lib-common-2.0.0-jdk-11.jar:?]
	at com.rapiddweller.common.converter.String2DateConverter.convert(String2DateConverter.java:102) ~[rd-lib-common-2.0.0-jdk-11.jar:?]
	at com.rapiddweller.common.converter.String2DateConverter.convert(String2DateConverter.java:61) ~[rd-lib-common-2.0.0-jdk-11.jar:?]
	at com.rapiddweller.common.converter.String2DateConverter.convert(String2DateConverter.java:34) ~[rd-lib-common-2.0.0-jdk-11.jar:?]
	at com.rapiddweller.common.converter.String2TimestampConverter.convert(String2TimestampConverter.java:68) ~[rd-lib-common-2.0.0-jdk-11.jar:?]
	at com.rapiddweller.common.converter.String2TimestampConverter.convert(String2TimestampConverter.java:31) ~[rd-lib-common-2.0.0-jdk-11.jar:?]
	at com.rapiddweller.common.converter.AnyConverter.convert(AnyConverter.java:94) ~[rd-lib-common-2.0.0-jdk-11.jar:?]
	at com.rapiddweller.common.converter.AnyConverter.convert(AnyConverter.java:71) ~[rd-lib-common-2.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.factory.SimpleTypeGeneratorFactory.createConstantGenerator(SimpleTypeGeneratorFactory.java:254) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.factory.SimpleTypeGeneratorFactory.createExplicitGenerator(SimpleTypeGeneratorFactory.java:109) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.factory.SimpleTypeGeneratorFactory.createExplicitGenerator(SimpleTypeGeneratorFactory.java:89) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.factory.TypeGeneratorFactory.createRootGenerator(TypeGeneratorFactory.java:83) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.factory.TypeGeneratorFactory.createGenerator(TypeGeneratorFactory.java:72) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.factory.MetaGeneratorFactory.createTypeGenerator(MetaGeneratorFactory.java:74) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.factory.InstanceGeneratorFactory.createSingleInstanceGenerator(InstanceGeneratorFactory.java:87) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.factory.ComponentBuilderFactory.createPartBuilder(ComponentBuilderFactory.java:161) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.factory.ComponentBuilderFactory.createComponentBuilder(ComponentBuilderFactory.java:107) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.factory.GenerationStepFactory.createGenerationStep(GenerationStepFactory.java:92) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.parser.xml.AbstractGenIterParser.parseTask(AbstractGenIterParser.java:330) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.parser.xml.AbstractGenIterParser.parseGenerate(AbstractGenIterParser.java:197) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.parser.xml.AbstractGenIterParser$1.evaluate(AbstractGenIterParser.java:155) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.parser.xml.AbstractGenIterParser$1.evaluate(AbstractGenIterParser.java:152) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.statement.LazyStatement.getRealStatement(LazyStatement.java:56) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.statement.LazyStatement.execute(LazyStatement.java:63) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.statement.SequentialStatement.executeSubStatements(SequentialStatement.java:72) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.statement.SequentialStatement.execute(SequentialStatement.java:61) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.BeneratorRootStatement.execute(BeneratorRootStatement.java:65) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.DescriptorRunner.execute(DescriptorRunner.java:128) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.DescriptorRunner.runWithoutShutdownHook(DescriptorRunner.java:102) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.engine.DescriptorRunner.run(DescriptorRunner.java:94) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.main.Benerator.runFile(Benerator.java:261) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.main.Benerator.run(Benerator.java:192) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.main.Benerator.runWithArgs(Benerator.java:164) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
	at com.rapiddweller.benerator.main.Benerator.main(Benerator.java:110) ~[rapiddweller-benerator-ce-3.0.0-jdk-11.jar:?]
Caused by: java.text.ParseException: Unparseable date: "now()"
	at java.text.DateFormat.parse(DateFormat.java:395) ~[?:?]
	at com.rapiddweller.common.converter.String2DateConverter.convert(String2DateConverter.java:91) ~[rd-lib-common-2.0.0-jdk-11.jar:?]
	... 32 more
[ERROR] 2022-12-11 17:57:56.511 [main] Benerator - Error: Failed to convert now()

Expected behavior
I'd expect the column to be either filled with a generated date (ignoring the default) or be omitted from the generation process.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
@jeenkhoorn jeenkhoorn changed the title Default value of 'now()' in date column causes issues Default value of 'now()' in date column causes error Dec 12, 2022
@ake2l ake2l self-assigned this Dec 17, 2022
@ake2l ake2l added the bug Something isn't working label Dec 17, 2022
@ake2l
Copy link
Member

ake2l commented Feb 2, 2023

We implement a handler for database date functions and extended tests with different variants. So it should be fixed now and included in a hotfix version we will release shortly.

@ake2l
Copy link
Member

ake2l commented Feb 3, 2023

release build is running, should work now , also integrated default time functions in the integration tests and demos of different database types

@ake2l ake2l closed this as completed Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants