<commit_before>package sql

import (
	"testing"

	"github.com/kr/pretty"
)

func TestQuery(t *testing.T) {
	people := Table("people")
	account := Table("account")
	avatar := Table("avatar")

	query := Select(
		people.AllColumns(),
		account.Column("email"),
		avatar.Column("url"),
	).
		From(people).
		InnerJoin(account.Column("person_id"), people.Column("id")).
		InnerJoin(avatar.Column("person_id"), people.Column("id")).
		Where(
		people.Column("first_name").Like("rob%").
			Or(people.Column("last_name").Like("rob%"))).
		Order(people.Column("first_name"), Ascending).
		Limit(20)

	expectedSQL := `
SELECT
  people.*,
  account.email,
  avatar.url
FROM people
INNER JOIN account ON account.person_id = people.id
INNER JOIN avatar ON avatar.person_id = people.id
WHERE (people.first_name LIKE 'rob%') OR (people.last_name LIKE 'rob%')
ORDER BY people.first_name ASC
LIMIT 20;
`

	pretty.Println("---")
	pretty.Println(expectedSQL)
	pretty.Println("---")
	pretty.Println(query.ToSQL())
	pretty.Println("---")

	if expectedSQL != query.ToSQL() {
		t.Fail()
	}
}<commit_msg>Updated test<commit_after>package sql

import (
	"testing"

	"github.com/kr/pretty"
)

func TestQuery(t *testing.T) {
	user := Table("user")
	account := Table("account")
	accountStatus := Table("account_status")

	query := Select(user.AllColumns()).
		From(user).
		InnerJoin(account.Column("user_id"), user.Column("id")). // InnerJoin() joins on the table in the first arg
		Where(account.Column("id").In(
			Select(accountStatus.Column("account_id")).
				From(accountStatus).
				Where(accountStatus.Column("status").InStringArray([]string{"PENDING", "ACTIVE"})),
		)).
		Order(user.Column("name").SortAscending()).
		Limit(100)

	expectedSQL := `
SELECT
  user.*
FROM user 
INNER JOIN account ON account.user_id = user.id
WHERE account.id IN (
SELECT
  account_status.account_id
FROM account_status 
WHERE account_status.status IN ('PENDING', 'ACTIVE')
)
ORDER BY user.name ASC
LIMIT 100
;`
	if expectedSQL != query.ToSQL() {
		pretty.Println("--Expected--")
		pretty.Println(expectedSQL)
		pretty.Println("--Received--")
		pretty.Println(query.ToSQL())
		pretty.Println("---")
		t.Fail()
	}
}
{'fraction_non_alphanumeric': 0.1781450872359963, 'fraction_numerical': 0.004591368227731864, 'mean_word_length': 4.615979381443299, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5171059', 'n_tokens_mistral': 820, 'n_tokens_neox': 746, 'n_words': 146}