Comments (1)
Hello @hongBry
Short answer
Slickless does not have a code generation.
Slightly longer answer
Slick's own code generator will use Slick's own HList implementation for tables with > 22 columns. However, it won't do a case class mapping automatically (only because no-one has written the code yet).
If you write your own case class you should be able to edit the generated code and modify the def *
implementation. You'll need to make it look like:
def * = (field1 :: field2...etc :: HNil).mapTo[YourCaseClassHere]
Make sure you change the table defintion to extend Table[YourCaseClassHere]
.
You can then work (insert, query, etc) in terms of the case class.
A long answer
If you really want to use shapeless HLists for some reason, I'm reasonably sure you can modify the generated code to use shapeless and Slickless.
Here's how. In the generated table code...
-
Add your case class.
-
Replace...
import slick.collection.heterogeneous._ import slick.collection.heterogeneous.syntax._
with:
import shapeless._ import slickless._ type HCons[H,T <: HList] = H :: T
(As an alternative to the type alias, search and replace
HCons
in the generated code with the shapeless::
). -
Change the row type to be your case class. For example, if your table is called
Wide
, and your case class is calledWideCC
then you'd end up with:class Wide(_tableTag: Tag) extends Table[WideCC](_tableTag, "WIDE") {
-
Change the definition of
*
to use the SlicklessmappedWith
method. For example:def * = (field1 :: field2 .... :: HNil).mappedWith(Generic[WideCC])
With those changes in place, you can query your wide tables and get back case classes.
from slickless.
Related Issues (16)
- Join Typelevel
- Support for Scala 2.12 HOT 2
- Support for Slick 3.4.0-M1 HOT 5
- Seems to depend on 3.3.2 of slick
- Question for the forked repo.
- Make slick and shapeless a runtime dependency HOT 1
- Support for extensible records HOT 3
- table with 144 columns inevitably causes a stackoverflowerror when compiling HOT 4
- Alternative to tails? HOT 3
- Old version information in README is wrong
- java.lang.StackOverflowError
- "No matching Shape found" error introduced in 0.3.3 HOT 5
- class > 22 fields stops compiling HOT 6
- Adopt sbt-ci-release
- MappedWith Not Working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slickless.