//
// 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 Layer = newLayerTable("arcgis", "layer", "")

type layerTable struct {
	postgres.Table

	// Columns
	Extent               postgres.ColumnString
	FeatureServiceItemID postgres.ColumnString
	Index                postgres.ColumnInteger

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

type LayerTable struct {
	layerTable

	EXCLUDED layerTable
}

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

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

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

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

func newLayerTable(schemaName, tableName, alias string) *LayerTable {
	return &LayerTable{
		layerTable: newLayerTableImpl(schemaName, tableName, alias),
		EXCLUDED:   newLayerTableImpl("", "excluded", ""),
	}
}

func newLayerTableImpl(schemaName, tableName, alias string) layerTable {
	var (
		ExtentColumn               = postgres.StringColumn("extent")
		FeatureServiceItemIDColumn = postgres.StringColumn("feature_service_item_id")
		IndexColumn                = postgres.IntegerColumn("index_")
		allColumns                 = postgres.ColumnList{ExtentColumn, FeatureServiceItemIDColumn, IndexColumn}
		mutableColumns             = postgres.ColumnList{ExtentColumn}
		defaultColumns             = postgres.ColumnList{}
	)

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

		//Columns
		Extent:               ExtentColumn,
		FeatureServiceItemID: FeatureServiceItemIDColumn,
		Index:                IndexColumn,

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