//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//

package table

import (
	"github.com/Gleipnir-Technology/jet/postgres"
)

var Csv = newCsvTable("fileupload", "csv", "")

type csvTable struct {
	postgres.Table

	// Columns
	Committed postgres.ColumnTimestamp
	FileID    postgres.ColumnInteger
	Rowcount  postgres.ColumnInteger
	Type      postgres.ColumnString

	AllColumns     postgres.ColumnList
	MutableColumns postgres.ColumnList
	DefaultColumns postgres.ColumnList
}

type CsvTable struct {
	csvTable

	EXCLUDED csvTable
}

// AS creates new CsvTable with assigned alias
func (a CsvTable) AS(alias string) *CsvTable {
	return newCsvTable(a.SchemaName(), a.TableName(), alias)
}

// Schema creates new CsvTable with assigned schema name
func (a CsvTable) FromSchema(schemaName string) *CsvTable {
	return newCsvTable(schemaName, a.TableName(), a.Alias())
}

// WithPrefix creates new CsvTable with assigned table prefix
func (a CsvTable) WithPrefix(prefix string) *CsvTable {
	return newCsvTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}

// WithSuffix creates new CsvTable with assigned table suffix
func (a CsvTable) WithSuffix(suffix string) *CsvTable {
	return newCsvTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}

func newCsvTable(schemaName, tableName, alias string) *CsvTable {
	return &CsvTable{
		csvTable: newCsvTableImpl(schemaName, tableName, alias),
		EXCLUDED: newCsvTableImpl("", "excluded", ""),
	}
}

func newCsvTableImpl(schemaName, tableName, alias string) csvTable {
	var (
		CommittedColumn = postgres.TimestampColumn("committed")
		FileIDColumn    = postgres.IntegerColumn("file_id")
		RowcountColumn  = postgres.IntegerColumn("rowcount")
		TypeColumn      = postgres.StringColumn("type_")
		allColumns      = postgres.ColumnList{CommittedColumn, FileIDColumn, RowcountColumn, TypeColumn}
		mutableColumns  = postgres.ColumnList{CommittedColumn, RowcountColumn, TypeColumn}
		defaultColumns  = postgres.ColumnList{}
	)

	return csvTable{
		Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),

		//Columns
		Committed: CommittedColumn,
		FileID:    FileIDColumn,
		Rowcount:  RowcountColumn,
		Type:      TypeColumn,

		AllColumns:     allColumns,
		MutableColumns: mutableColumns,
		DefaultColumns: defaultColumns,
	}
}
