@@ -61,12 +61,16 @@ object CodegenPlugin extends sbt.AutoPlugin with PluginDBSupport {
6161 lazy val slickCodegenIncludedTableTypes : SettingKey [Seq [String ]] =
6262 settingKey[Seq [String ]](" Table types that slick schema can be generated for" )
6363
64- lazy val slickCodegenExcludedTables : SettingKey [Seq [String ]] =
65- settingKey[Seq [String ]](" Tables that should be excluded" )
64+ lazy val slickCodegenExcludedTables : SettingKey [Seq [(String , String )]] =
65+ settingKey[Seq [(String , String )]](
66+ " Tables that should be excluded" +
67+ " \n key is the schema name, value is the table name."
68+ )
6669
67- lazy val slickCodegenIncludedTables : SettingKey [Seq [String ]] =
68- settingKey[Seq [String ]](
69- " Tables that should be included. If this list is not nil, only the included tables minus excluded will be taken."
70+ lazy val slickCodegenIncludedTables : SettingKey [Seq [(String , String )]] =
71+ settingKey[Seq [(String , String )]](
72+ " Tables that should be included. If this list is not nil, only the included tables minus excluded will be taken." +
73+ " \n key is the schema name, value is the table name."
7074 )
7175
7276 /** Define a new configuration scope for slick code gen,
@@ -166,10 +170,21 @@ object CodegenPlugin extends sbt.AutoPlugin with PluginDBSupport {
166170 throw new RuntimeException (" Failed to run slick-codegen: " + e.getMessage, e)
167171 }
168172
173+ def containsTable (seq : Seq [(String , String )], t : MTable ): Boolean = {
174+ seq.exists { case (schema, name) => t.name.schema.contains(schema) && t.name.name == name }
175+ }
176+
169177 val tables = MTable
170178 .getTables(None , None , None , Some (tableTypes))
171- .map(ts => ts.filter(t => included.isEmpty || (included contains t.name.name)))
172- .map(ts => ts.filterNot(t => excluded contains t.name.name))
179+ .map (
180+ ts =>
181+ // only include specified tables
182+ // if included is empty, then include all tables
183+ // if included is not empty, then only include the specified tables
184+ (if (included.isEmpty) ts else ts.filter(t => containsTable(included, t)))
185+ // if excluded is not empty, then exclude the specified tables
186+ .filterNot(t => containsTable(excluded, t))
187+ )
173188
174189 val dbio = for {
175190 m <- driver.createModel(Some (tables))
0 commit comments