honeyeql icon indicating copy to clipboard operation
honeyeql copied to clipboard

Support for in-memory databases (h2) for tests?

Open ieugen opened this issue 4 years ago • 3 comments

Hi,

It would be nice to have honeyeql work with in-memory databases. I don't think it should do much - just start initially.

While playing around with graphqlize I've tried to fix the failing test in graphqlize-demo. I had no success.

I think it should be usefull for tests. Another option would be to use docker containers for tests.

This is what I get for using an H2 datasource.

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.graphqlize.java.springboot.GraphQLizeResolverProvider]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: No method in multimethod 'get-db-config' for dispatch value: H2
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:216)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:310)
	... 129 more
Caused by: java.lang.IllegalArgumentException: No method in multimethod 'get-db-config' for dispatch value: H2
	at clojure.lang.MultiFn.getFn(MultiFn.java:156)
	at clojure.lang.MultiFn.invoke(MultiFn.java:229)
	at honeyeql.meta_data$fetch.invokeStatic(meta_data.clj:328)
	at honeyeql.meta_data$fetch.invoke(meta_data.clj:324)
	at honeyeql.db$initialize.invokeStatic(db.clj:12)
	at honeyeql.db$initialize.invoke(db.clj:7)
	at graphqlize.lacinia.core$schema.invokeStatic(core.clj:39)
	at graphqlize.lacinia.core$schema.invoke(core.clj:38)
	at graphqlize.java_interop$initialize.invokeStatic(java_interop.clj:10)
	at graphqlize.java_interop$initialize.invoke(java_interop.clj:9)
	at clojure.lang.Var.invoke(Var.java:384)
	at org.graphqlize.java.GraphQLizeResolver.<init>(GraphQLizeResolver.java:17)
	at org.graphqlize.java.springboot.GraphQLizeResolverProvider.<init>(GraphQLizeResolverProvider.java:16)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:203)
	... 131 more

There is also a few versions of sakila db for h2. https://github.com/maxandersen/sakila-h2

ieugen avatar Apr 13 '20 18:04 ieugen

The ideal test suite for HoneyEQL has to interact directly with the database (Postgres & MySQL) and running it against an H2 database is not a foolproof solution.

As mentioned in this comment, once we have the integration test suite in place, having H2 database support would be redundant.

To give you some more context, the generated SQL is vendor-specific and generating one for H2 is not going to be a good value addition to this library.

tamizhvendan avatar Apr 15 '20 06:04 tamizhvendan

Thanks for the great library! I just want to mention that H2 or SQLite support would be really valuable, not just for testing but for small or embedded applications that don't need a full Postgres or MySQL.

Not that I expect you to implement this :D just saying it could be valuable if someone would be interested in doing that.

plexus avatar Jun 15 '21 06:06 plexus

Sorry, @plexus for the delayed response. I got the use case.

From the implementation perspective, all we need is separate adapter implementations. I am open to accepting the MR if someone is willing to do that!

tamizhvendan avatar Aug 24 '21 12:08 tamizhvendan

Closing this as the library now have an integration test suite.

tamizhvendan avatar Aug 14 '23 10:08 tamizhvendan