-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
392 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
jOOQ-demo-oss/jOOQ-demo-java/src/test/java/org/jooq/demo/java/Demo17Policies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.jooq.demo.java; | ||
|
||
import org.jooq.DSLContext; | ||
import org.jooq.demo.AbstractDemo; | ||
import org.jooq.impl.*; | ||
import org.junit.Test; | ||
|
||
import static org.jooq.demo.java.db.Tables.CUSTOMER; | ||
import static org.jooq.demo.java.db.Tables.PAYMENT; | ||
import static org.jooq.demo.java.db.Tables.RENTAL; | ||
import static org.jooq.impl.DSL.sum; | ||
|
||
public class Demo17Policies extends AbstractDemo { | ||
|
||
@Test | ||
public void testPolicy() { | ||
title("Policies allow for filtering out data in DML statements"); | ||
|
||
// Computed columns are a commercial only feature | ||
|
||
// | ||
// // Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER and PAYMENT tables | ||
// DSLContext c = ctx.configuration().derive( | ||
// new DefaultPolicyProvider() | ||
// .append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L)) | ||
// .append(PAYMENT, PAYMENT.CUSTOMER_ID.eq(1L)) | ||
// ).dsl(); | ||
// | ||
// c.select(PAYMENT.customer().FIRST_NAME, PAYMENT.customer().LAST_NAME, PAYMENT.AMOUNT) | ||
// .from(PAYMENT) | ||
// .fetch(); | ||
// | ||
// | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
|
||
@Test | ||
public void testPolicyInheritance() { | ||
title("Policies can be inherited between tables"); | ||
|
||
// Computed columns are a commercial only feature | ||
|
||
// | ||
// // Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER table | ||
// // This policy is inherited by various other tables by path specification | ||
// DSLContext c1 = ctx.configuration().derive( | ||
// new DefaultPolicyProvider() | ||
// .append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L), | ||
// PAYMENT.customer(), | ||
// RENTAL.customer()) | ||
// ).dsl(); | ||
// | ||
// c1.select(sum(PAYMENT.AMOUNT)) | ||
// .from(PAYMENT) | ||
// .fetch(); | ||
// | ||
// | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
jOOQ-demo-oss/jOOQ-demo-kotlin/src/test/kotlin/org/jooq/demo/kotlin/Demo17Policies.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.jooq.demo.kotlin | ||
|
||
import org.jooq.demo.AbstractDemo | ||
import org.jooq.demo.kotlin.db.tables.references.CUSTOMER | ||
import org.jooq.demo.kotlin.db.tables.references.PAYMENT | ||
import org.jooq.demo.kotlin.db.tables.references.RENTAL | ||
import org.jooq.impl.DSL | ||
import org.jooq.impl.* | ||
import org.junit.Test | ||
|
||
class Demo17Policies : AbstractDemo() { | ||
|
||
@Test | ||
fun testPolicy() { | ||
title("Policies allow for filtering out data in DML statements") | ||
|
||
// Computed columns are a commercial only feature | ||
|
||
// | ||
// // Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER and PAYMENT tables | ||
// val c = ctx.configuration().derive( | ||
// DefaultPolicyProvider() | ||
// .append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L)) | ||
// .append(PAYMENT, PAYMENT.CUSTOMER_ID.eq(1L)) | ||
// ).dsl() | ||
// | ||
// c.select( | ||
// PAYMENT.customer().FIRST_NAME, | ||
// PAYMENT.customer().LAST_NAME, | ||
// PAYMENT.AMOUNT | ||
// ) | ||
// .from(PAYMENT) | ||
// .fetch() | ||
// | ||
// | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
|
||
@Test | ||
fun testPolicyInheritance() { | ||
title("Policies can be inherited between tables") | ||
|
||
// Computed columns are a commercial only feature | ||
|
||
// | ||
// // Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER table | ||
// // This policy is inherited by various other tables by path specification | ||
// val c1 = ctx.configuration().derive( | ||
// DefaultPolicyProvider() | ||
// .append( | ||
// CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L), | ||
// PAYMENT.customer(), | ||
// RENTAL.customer() | ||
// ) | ||
// ).dsl() | ||
// | ||
// c1.select(DSL.sum(PAYMENT.AMOUNT)) | ||
// .from(PAYMENT) | ||
// .fetch() | ||
// | ||
// | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
jOOQ-demo-oss/jOOQ-demo-scala/src/test/scala/org/jooq/demo/skala/Demo17Policies.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.jooq.demo.scala | ||
|
||
import org.jooq.DSLContext | ||
import org.jooq.demo.AbstractDemo | ||
import org.jooq.demo.AbstractDemo._ | ||
import org.jooq.impl._ | ||
import org.junit.Test | ||
import org.jooq.demo.skala.db.Tables._ | ||
import org.jooq.impl.DSL.sum | ||
|
||
|
||
class Demo17Policies extends AbstractDemo { | ||
|
||
@Test | ||
def testPolicy(): Unit = { | ||
title("Policies allow for filtering out data in DML statements") | ||
|
||
// Computed columns are a commercial only feature | ||
|
||
// | ||
// // Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER and PAYMENT tables | ||
// val c = ctx.configuration.derive(new DefaultPolicyProvider() | ||
// .append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L)) | ||
// .append(PAYMENT, PAYMENT.CUSTOMER_ID.eq(1L)) | ||
// ).dsl | ||
// | ||
// c.select( | ||
// PAYMENT.customer.FIRST_NAME, | ||
// PAYMENT.customer.LAST_NAME, | ||
// PAYMENT.AMOUNT) | ||
// .from(PAYMENT) | ||
// .fetch | ||
// | ||
// | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
|
||
@Test | ||
def testPolicyInheritance(): Unit = { | ||
title("Policies can be inherited between tables") | ||
|
||
// Computed columns are a commercial only feature | ||
|
||
// | ||
// // Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER table | ||
// // This policy is inherited by various other tables by path specification | ||
// val c1 = ctx.configuration.derive(new DefaultPolicyProvider() | ||
// .append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L), | ||
// PAYMENT.customer, | ||
// RENTAL.customer | ||
// ) | ||
// ).dsl | ||
// | ||
// c1.select(sum(PAYMENT.AMOUNT)) | ||
// .from(PAYMENT) | ||
// .fetch | ||
// | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
jOOQ-demo-pro/jOOQ-demo-java/src/test/java/org/jooq/demo/java/Demo17Policies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.jooq.demo.java; | ||
|
||
import org.jooq.DSLContext; | ||
import org.jooq.demo.AbstractDemo; | ||
import org.jooq.impl.*; | ||
import org.junit.Test; | ||
|
||
import static org.jooq.demo.java.db.Tables.CUSTOMER; | ||
import static org.jooq.demo.java.db.Tables.PAYMENT; | ||
import static org.jooq.demo.java.db.Tables.RENTAL; | ||
import static org.jooq.impl.DSL.sum; | ||
|
||
public class Demo17Policies extends AbstractDemo { | ||
|
||
@Test | ||
public void testPolicy() { | ||
title("Policies allow for filtering out data in DML statements"); | ||
|
||
// Computed columns are a commercial only feature | ||
/* [pro] */ | ||
|
||
// Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER and PAYMENT tables | ||
DSLContext c = ctx.configuration().derive( | ||
new DefaultPolicyProvider() | ||
.append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L)) | ||
.append(PAYMENT, PAYMENT.CUSTOMER_ID.eq(1L)) | ||
).dsl(); | ||
|
||
c.select(PAYMENT.customer().FIRST_NAME, PAYMENT.customer().LAST_NAME, PAYMENT.AMOUNT) | ||
.from(PAYMENT) | ||
.fetch(); | ||
|
||
/* [/pro] */ | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
|
||
@Test | ||
public void testPolicyInheritance() { | ||
title("Policies can be inherited between tables"); | ||
|
||
// Computed columns are a commercial only feature | ||
/* [pro] */ | ||
|
||
// Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER table | ||
// This policy is inherited by various other tables by path specification | ||
DSLContext c1 = ctx.configuration().derive( | ||
new DefaultPolicyProvider() | ||
.append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L), | ||
PAYMENT.customer(), | ||
RENTAL.customer()) | ||
).dsl(); | ||
|
||
c1.select(sum(PAYMENT.AMOUNT)) | ||
.from(PAYMENT) | ||
.fetch(); | ||
|
||
/* [/pro] */ | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
jOOQ-demo-pro/jOOQ-demo-kotlin/src/test/kotlin/org/jooq/demo/kotlin/Demo17Policies.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.jooq.demo.kotlin | ||
|
||
import org.jooq.demo.AbstractDemo | ||
import org.jooq.demo.kotlin.db.tables.references.CUSTOMER | ||
import org.jooq.demo.kotlin.db.tables.references.PAYMENT | ||
import org.jooq.demo.kotlin.db.tables.references.RENTAL | ||
import org.jooq.impl.DSL | ||
import org.jooq.impl.* | ||
import org.junit.Test | ||
|
||
class Demo17Policies : AbstractDemo() { | ||
|
||
@Test | ||
fun testPolicy() { | ||
title("Policies allow for filtering out data in DML statements") | ||
|
||
// Computed columns are a commercial only feature | ||
/* [pro] */ | ||
|
||
// Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER and PAYMENT tables | ||
val c = ctx.configuration().derive( | ||
DefaultPolicyProvider() | ||
.append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L)) | ||
.append(PAYMENT, PAYMENT.CUSTOMER_ID.eq(1L)) | ||
).dsl() | ||
|
||
c.select( | ||
PAYMENT.customer().FIRST_NAME, | ||
PAYMENT.customer().LAST_NAME, | ||
PAYMENT.AMOUNT | ||
) | ||
.from(PAYMENT) | ||
.fetch() | ||
|
||
/* [/pro] */ | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
|
||
@Test | ||
fun testPolicyInheritance() { | ||
title("Policies can be inherited between tables") | ||
|
||
// Computed columns are a commercial only feature | ||
/* [pro] */ | ||
|
||
// Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER table | ||
// This policy is inherited by various other tables by path specification | ||
val c1 = ctx.configuration().derive( | ||
DefaultPolicyProvider() | ||
.append( | ||
CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L), | ||
PAYMENT.customer(), | ||
RENTAL.customer() | ||
) | ||
).dsl() | ||
|
||
c1.select(DSL.sum(PAYMENT.AMOUNT)) | ||
.from(PAYMENT) | ||
.fetch() | ||
|
||
/* [/pro] */ | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
jOOQ-demo-pro/jOOQ-demo-scala/src/test/scala/org/jooq/demo/skala/Demo17Policies.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.jooq.demo.scala | ||
|
||
import org.jooq.DSLContext | ||
import org.jooq.demo.AbstractDemo | ||
import org.jooq.demo.AbstractDemo._ | ||
import org.jooq.impl._ | ||
import org.junit.Test | ||
import org.jooq.demo.skala.db.Tables._ | ||
import org.jooq.impl.DSL.sum | ||
|
||
|
||
class Demo17Policies extends AbstractDemo { | ||
|
||
@Test | ||
def testPolicy(): Unit = { | ||
title("Policies allow for filtering out data in DML statements") | ||
|
||
// Computed columns are a commercial only feature | ||
/* [pro] */ | ||
|
||
// Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER and PAYMENT tables | ||
val c = ctx.configuration.derive(new DefaultPolicyProvider() | ||
.append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L)) | ||
.append(PAYMENT, PAYMENT.CUSTOMER_ID.eq(1L)) | ||
).dsl | ||
|
||
c.select( | ||
PAYMENT.customer.FIRST_NAME, | ||
PAYMENT.customer.LAST_NAME, | ||
PAYMENT.AMOUNT) | ||
.from(PAYMENT) | ||
.fetch | ||
|
||
/* [/pro] */ | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
|
||
@Test | ||
def testPolicyInheritance(): Unit = { | ||
title("Policies can be inherited between tables") | ||
|
||
// Computed columns are a commercial only feature | ||
/* [pro] */ | ||
|
||
// Queries run with this configuration will only be able to access CUSTOMER_ID = 1 on the CUSTOMER table | ||
// This policy is inherited by various other tables by path specification | ||
val c1 = ctx.configuration.derive(new DefaultPolicyProvider() | ||
.append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(1L), | ||
PAYMENT.customer, | ||
RENTAL.customer | ||
) | ||
).dsl | ||
|
||
c1.select(sum(PAYMENT.AMOUNT)) | ||
.from(PAYMENT) | ||
.fetch | ||
/* [/pro] */ | ||
|
||
// More information here: | ||
// - https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/ | ||
} | ||
} |