<commit_before>/*******************************************************************************
 * Copyright 2010 <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package org.squeryl.tests.schooldb


import java.sql.SQLException
import org.squeryl.annotations.{Column}
import org.squeryl.tests.QueryTester
import java.util.Date
import java.text.SimpleDateFormat
import org.squeryl.dsl.{GroupWithMeasures}
import org.squeryl.dsl._
import ast.TypedExpressionNode
import org.squeryl._
import adapters.{PostgreSqlAdapter, OracleAdapter, MySQLAdapter}
import internals.FieldReferenceLinker

class SchoolDbObject extends KeyedEntity[Int] {
  var id: Int = 0
}

class Student(var name: String, var lastName: String, var age: Option[Int], var gender: Int, var addressId: Option[Int], var isMultilingual: Option[Boolean])
  extends SchoolDbObject {

  def this() = this("","",Some(0),0, Some(0), Some(false))

  override def toString = "Student:" + id + ":" + name
}

case class Course(var name: String, var startDate: Date, var finalExamDate: Option[Date],
  @Column("meaninglessLongZ")
  var meaninglessLong: Long,
  @Column("meaninglessLongOption")
  var meaninglessLongOption: Option[Long], val confirmed: Boolean)
  extends SchoolDbObject with Optimistic {

  def occVersionNumberZ = occVersionNumber

  def this() = this("", null, Some(new Date), 0, Some(0), false)
  override def toString = "Course:" + id + ":" + name

  var rawData = {
    val a = new Array[Byte](1)
    a(0) = 5
    a
  }
}

class CourseSubscription(var courseId: Int, var studentId: Int)
  extends SchoolDbObject {

  def this() = this(0,0)
  override def toString = "CourseSubscription:" + id
}

class CourseAssignment(var courseId: Int, var professorId: Long)
  extends SchoolDbObject {

  def this() = this(0,0)
  override def toString = "CourseAssignment:" + id
}

class Address(var streetName: String, var numberz:Int, var numberSuffix:Option[String], var appNumber: Option[Int], var appNumberSuffix: Option[String])
  extends SchoolDbObject {

  def this() = this(null,0, Some(""),Some(0), Some(""))

  override def toString = "rue " + streetName 
}

class Professor(var lastName: String, var yearlySalary: Float, var weight: Option[Float], var yearlySalaryBD: BigDecimal, var weightInBD: Option[BigDecimal]) extends KeyedEntity[Long] {

  var id: Long = 0
  def this() = this("", 0.0F, Some(0.0F), 80.0F, Some(0))
  override def toString = "Professor:" + id

  import org.squeryl.PrimitiveTypeMode._
  
  //def assignments =
    //oneToMany(this, SDB.courseAssigments) ((p, ca) => p.id === ca.professorId)

  //def assign = Relation(this, SDB.courseAssigments) {}
//  def assignments =
//    One(this) ToMany(SDB.courseAssigments) on(p=>p.id, ca => ca.professorId)
}

object SDB extends SchoolDb

class SchoolDb extends Schema with QueryTester {

  import org.squeryl.PrimitiveTypeMode._

  override val name = {
    if(Session.currentSession.databaseAdapter.isInstanceOf[OracleAdapter])
      Some("squeryl")
    else
      None
  }

  override def columnNameFromPropertyName(n:String) =
    NamingConventionTransforms.camelCase2underScore(n)

  /**
   * Let's illustrate the support for crappy table naming convention !
   */
  override def tableNameFromClassName(n:String) =
    "T_" + n

  val professors = table[Professor]
  
  val students = table[Student]
  
  val addresses = table[Address]

  val courses = table[Course]
<commit_msg>adapt test case for Postgres FQNs (fully qualified names)<commit_after>/*******************************************************************************
 * Copyright 2010 <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package org.squeryl.tests.schooldb


import java.sql.SQLException
import org.squeryl.annotations.{Column}
import org.squeryl.tests.QueryTester
import java.util.Date
import java.text.SimpleDateFormat
import org.squeryl.dsl.{GroupWithMeasures}
import org.squeryl.dsl._
import ast.TypedExpressionNode
import org.squeryl._
import adapters.{PostgreSqlAdapter, OracleAdapter, MySQLAdapter}
import internals.FieldReferenceLinker

class SchoolDbObject extends KeyedEntity[Int] {
  var id: Int = 0
}

class Student(var name: String, var lastName: String, var age: Option[Int], var gender: Int, var addressId: Option[Int], var isMultilingual: Option[Boolean])
  extends SchoolDbObject {

  def this() = this("","",Some(0),0, Some(0), Some(false))

  override def toString = "Student:" + id + ":" + name
}

case class Course(var name: String, var startDate: Date, var finalExamDate: Option[Date],
  @Column("meaninglessLongZ")
  var meaninglessLong: Long,
  @Column("meaninglessLongOption")
  var meaninglessLongOption: Option[Long], val confirmed: Boolean)
  extends SchoolDbObject with Optimistic {

  def occVersionNumberZ = occVersionNumber

  def this() = this("", null, Some(new Date), 0, Some(0), false)
  override def toString = "Course:" + id + ":" + name

  var rawData = {
    val a = new Array[Byte](1)
    a(0) = 5
    a
  }
}

class CourseSubscription(var courseId: Int, var studentId: Int)
  extends SchoolDbObject {

  def this() = this(0,0)
  override def toString = "CourseSubscription:" + id
}

class CourseAssignment(var courseId: Int, var professorId: Long)
  extends SchoolDbObject {

  def this() = this(0,0)
  override def toString = "CourseAssignment:" + id
}

class Address(var streetName: String, var numberz:Int, var numberSuffix:Option[String], var appNumber: Option[Int], var appNumberSuffix: Option[String])
  extends SchoolDbObject {

  def this() = this(null,0, Some(""),Some(0), Some(""))

  override def toString = "rue " + streetName 
}

class Professor(var lastName: String, var yearlySalary: Float, var weight: Option[Float], var yearlySalaryBD: BigDecimal, var weightInBD: Option[BigDecimal]) extends KeyedEntity[Long] {

  var id: Long = 0
  def this() = this("", 0.0F, Some(0.0F), 80.0F, Some(0))
  override def toString = "Professor:" + id

  import org.squeryl.PrimitiveTypeMode._
  
  //def assignments =
    //oneToMany(this, SDB.courseAssigments) ((p, ca) => p.id === ca.professorId)

  //def assign = Relation(this, SDB.courseAssigments) {}
//  def assignments =
//    One(this) ToMany(SDB.courseAssigments) on(p=>p.id, ca => ca.professorId)
}

object SDB extends SchoolDb

class SchoolDb extends Schema with QueryTester {

  import org.squeryl.PrimitiveTypeMode._

  override val name = {
    if(Session.currentSession.databaseAdapter.isInstanceOf[OracleAdapter])
      Some("squeryl")
    else if(Session.currentSession.databaseAdapter.isInstanceOf[PostgreSqlAdapter])
      Some("public")
    else
      None
  }

  override def columnNameFromPropertyName(n:String) =
    NamingConventionTransforms.camelCase2underScore(n)

  /**
   * Let's illustrate the support for crappy table naming convention !
   */
  override def tableNameFromClassName(n:String) =
    "T_" + n

  val professors = table[Professor]
  
  val students = table[Student]
  
  val addresses = table[Address]

  val courses = table[Course]

{'fraction_non_alphanumeric': 0.14460334922381127, 'fraction_numerical': 0.008067473414008068, 'mean_word_length': 4.646652864044168, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '370454', 'n_tokens_mistral': 2523, 'n_tokens_neox': 2420, 'n_words': 741}