package query_test

import (
	"fmt"
	"testing"

	"github.com/nexuscrm/backend/pkg/query"
	"github.com/stretchr/testify/assert"
)

func TestBuilderExtension(t *testing.T) {
	// Test JoinOn
	// We need a dummy builder. From() creates one.
	b := query.From("_System_MainTable")
	b.JoinOn("LEFT JOIN", "_System_JoinedTable", "j", "_System_MainTable.Id", "=", "j.OwnerId")

	res := b.Build()
	sql := res.SQL

	// Expectations:
	// main_table.Id -> main_table.Id
	// j.OwnerId -> j.OwnerId

	// Check standard SQL construction
	assert.Contains(t, sql, "LEFT JOIN `_System_JoinedTable` as `j` ON")
	assert.Contains(t, sql, "_System_MainTable.Id = j.OwnerId")

	fmt.Println("Generated SQL:", sql)
}
