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

Fixed wrong escaping in code examples #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: squeryl
markdown: kramdown
pygments: true
highlighter: rouge
99 changes: 39 additions & 60 deletions docs/0.9.5/0.9.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,90 +19,69 @@ only it’s companion object
#### In the next example, we defined an object SquerylEntrypointForMyApp that will be imported in an application wherever the DSL is used.

<script type="syntaxhighlighter" class="brush: scala">
<![CDATA[



import org.squeryl.\_
import org.squeryl.dsl.\_
import org.joda.time.\_
import java.sql.Timestamp
import org.squeryl._
import org.squeryl.dsl._
import org.joda.time._
import java.sql.Timestamp
import java.sql.ResultSet

object SquerylEntrypointForMyApp extends PrimitiveTypeMode {

// optionally define keyed entities :
implicit object courseKED extends KeyedEntityDef\[Course,Int\] {
def getId(a:Course) = a.id
def isPersisted(a:Course) = a.id \> 0
def idPropertyName = “id”
override def optimisticCounterPropertyName = Some(“occVersionNumber”)
}

// optionally define custom types :

implicit val jodaTimeTEF = new NonPrimitiveJdbcMapper\[Timestamp,
DateTime, TTimestamp\](timestampTEF, this) {

/
\* Here we implement functions fo convert to and from the native JDBC
type
\*/
// optionally define keyed entities:
implicit object courseKED extends KeyedEntityDef[Course,Int] {
def getId(a:Course) = a.id
def isPersisted(a:Course) = a.id > 0
def idPropertyName = “id”
override def optimisticCounterPropertyName = Some(“occVersionNumber”)
}

def convertFromJdbc(t: Timestamp) = new DateTime(t)
def convertToJdbc(t: DateTime) = new Timestamp(t.getMillis())
}
// optionally define custom types:
implicit val jodaTimeTEF = new NonPrimitiveJdbcMapper[Timestamp, DateTime, TTimestamp](timestampTEF, this) {

/
\* We define this one here to allow working with Option of our new type,
this allso
\* allows the ‘nvl’ function to work
\*/
implicit val optionJodaTimeTEF =
new TypedExpressionFactory\[Option\[DateTime\], TOptionTimestamp\]
with DeOptionizer\[Timestamp, DateTime, TTimestamp, Option\[DateTime\],
TOptionTimestamp\] {
/* Here we implement functions fo convert to and from the native JDBC type*/

val deOptionizer = jodaTimeTEF
}
def convertFromJdbc(t: Timestamp) = new DateTime(t)
def convertToJdbc(t: DateTime) = new Timestamp(t.getMillis())
}

/
\* the following are necessary for the AST lifting
\*/
implicit def jodaTimeToTE(s: DateTime) = jodaTimeTEF.create(s)
/* We define this one here to allow working with Option of our new type, this also allows the ‘nvl’ function to work */
implicit val optionJodaTimeTEF =
new TypedExpressionFactory[Option[DateTime], TOptionTimestamp]
with DeOptionizer[Timestamp, DateTime, TTimestamp, Option[DateTime], TOptionTimestamp] {
val deOptionizer = jodaTimeTEF
}

implicit def optionJodaTimeToTE(s: Option\[DateTime\]) =
optionJodaTimeTEF.create(s)
}
/* the following are necessary for the AST lifting */
implicit def jodaTimeToTE(s: DateTime) = jodaTimeTEF.create(s)

// elsewhere in the application :

import SquerylEntrypointForMyApp.\_
implicit def optionJodaTimeToTE(s: Option[DateTime]) =
optionJodaTimeTEF.create(s)
}

// elsewhere in the application:

import SquerylEntrypointForMyApp._
]]>

</script>

**Warning**: Although deprecared, the org.squeryl.PrimitiveTypeMode
companion object can still be used for backward compatibility.
If it is used, it **cannot** be used in a same application with other
instance of the
org.squeryl.PrimitiveTypeMode trait.
**Warning**: Although deprecated, the org.squeryl.PrimitiveTypeMode companion object can still be used for backward compatibility.
If it is used, it **cannot** be used in a same application with other instance of the org.squeryl.PrimitiveTypeMode trait.

<script type="syntaxhighlighter" class="brush: scala">



// WRONG, do not do this :
<![CDATA[
// WRONG, do not do this:

object SquerylEntrypointForMyApp extends org.squeryl.PrimitiveTypeMode

import SquerylEntrypointForMyApp.\_
import SquerylEntrypointForMyApp._

// elsewhere in the application

import org.squeryl.PrimitiveTypeMode.\_
}


import org.squeryl.PrimitiveTypeMode._
]]>

</script>
32 changes: 10 additions & 22 deletions docs/0.9.5/arbitrary-select-expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,13 @@ Sometimes the expressions needs to be evaluated on the database side,
this is what the **&** function does :

<script type="syntaxhighlighter" class="brush: scala">
<![CDATA[
// the * is done on the client side:
from(artists)(a => select(a.id * 1000))



// the \* is done on the client side :

from(artists)(a =\>
select(a.id \* 1000)
)

// in this case it is computed by the database :

from(artists)(a =\>
select(&(a.id \* 1000))
)


// in this case it is computed by the database:
from(artists)(a => select(&(a.id * 1000)))
]]>
</script>

- Note that the return type are equivalent in both cases, i.e. both
Expand All @@ -36,13 +27,10 @@ select(&(a.id \* 1000))
A select can have more than one invocation of & :

<script type="syntaxhighlighter" class="brush: scala">
<![CDATA[

val q: Query[Tuple2[Double, String]] = from(artists)(a =>
select((&(a.id * 1000), &(a.firstName || a.lastName))))


val q: Query\[Tuple2\[Double, String\]\] =
from(artists)(a =\>
select((&(a.id \* 1000), &(a.firstName \|\| a.lastName)))
)


]]>
</script>
Loading