Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7193399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:09:46+00:00 2026-05-28T20:09:46+00:00

I’m currently reading the scala version of play’s yabe tutorial. yabe stands for yet

  • 0

I’m currently reading the scala version of play’s yabe tutorial. yabe stands for yet another blog engine and naturally at some point in the tutorial data needs to be stored. The first sql evolution is this one:

    # Users schema

# ---!Ups

CREATE TABLE User(
id bigint(20) NOT NULL AUTO_INCREMENT,
email varchar(255) NOT NULL,
password varchar(255) NOT NULL,
fullname varchar(255) NOT NULL,
isAdmin boolean NOT NULL,
PRIMARY KEY (id)
);

# --- !Downs

DROP TABLE User; 

After that tables for posts and comments are added. On the scala side each database entry can be mapped to a case class. Its companion object extends the trait Magic and implements various helper functions. The problem is caused by this code from the companion object of the Post class. You only need to look at the sql query:

def allWithAuthor:List[(Post,User)] = 
    SQL(
        """
            select * from Post p 
            join User u on p.author_id = u.id 
            order by p.postedAt desc
        """
    ).as( Post ~< User ^^ flatten * )

I admit that although I understand what the code does I would never have come up with this on my own.

In order to test the code the following tests are run:

it should "create a Post" in {

    User.create(User(Id(1), "bob@gmail.com", "secret", "Bob", false))     
    val users= User.find("id={id}").on("id"->1).as(User*)
}

This test finishes just fine.
Scala’s syntax adds some complexity but you can clearly see that the test queries for a user with id equals 1.
The problem shows up in this test:

it should "retrieve Posts with author" in {

    User.create(User(Id(1), "bob@gmail.com", "secret", "Bob", false)) 
    Post.create(Post(NotAssigned, "My 1st post", "Hello world", new Date, 1))

    val posts = Post.allWithAuthor

    posts.length should be (1)

    val (post,author) = posts.head

    post.title should be ("My 1st post")
    author.fullname should be ("Bob")
}

The test fails with the error message:

ColumnNotFound(User.id) In /test/Tests.scala, line 41: val posts =
Post.allWithAuthor

How can the column id disappear like that? I didn’t change anything in the sql or scala code. Just swapping the tests “switches” the error on an off. Somehow this sql code

            select * from Post p 
            join User u on p.author_id = u.id 
            order by p.postedAt desc

doesn’t find the id while this scala/sql code

val users= User.find("id={id}").on("id"->1).as(User*)

does.

Can you explain what went wrong ?
Here’s the link to the tutorial http://scala.playframework.org/documentation/scala-0.9.1/guide1

UPDATE:

I’ve read this question:
ColumnNotFound problem with Magic in play scala

and following a comment edited the query. The sql itself hasn’t changed but I’ve pasted it all in one single line:

def allWithAuthor:List[(Post,User)] = 
    SQL(
        """select * from Post p join User u on p.author_id = u.id order by p.postedAt desc"""
    ).as( Post ~< User ^^ flatten * )

It’s a miracle: Now the column is found. If the query is longer than one line the test complains with the strange ColumnNotFoundError but with a oneliner everything’s fine.

How can something like this happen ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:09:47+00:00Added an answer on May 28, 2026 at 8:09 pm

    I guess your file is encoded with windows encoding. If you have windows encoding and your sql contains line break, there is this kind of problem.

    Try with an UTF-8 encoded file

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.