kvesteri / postgresql-audit

Audit trigger for PostgreSQL
BSD 2-Clause "Simplified" License
126 stars 28 forks source link

the bigint data type does not have a default operator class for the "gist" accessor #53

Closed EnriqueGautoSand closed 3 years ago

EnriqueGautoSand commented 3 years ago

i have the next error using with flask-appbuilder

from flask_appbuilder import Model
from . import appbuilder, db
from postgresql_audit import versioning_manager
versioning_manager.init(db.Model)
class TipoPersona(Model):
    __tablename__ = 'tipoPersona'
    idTipoPersona = Column(Integer, primary_key=True)
    tipoPersona = Column(String(30), nullable=False, unique=True)

    #defino como se representara al ser llamado
    def __repr__(self):
        return f'{self.tipoPersona}'

class TipoClaves(Model):
    __tablename__ = 'tiposClave'
    id = Column(Integer, primary_key=True)
    tipoClave = Column(String(30), nullable=False, unique=True)

    def __repr__(self):
        return f'{self.tipoClave}'

class Proveedor(Model):
    __tablename__ = 'proveedor'
    __versioned__ = {}
    id = Column(Integer, primary_key=True)
    cuit=Column(String(30),nullable=False,unique=True)
    nombre = Column(String(30),nullable=False)
    apellido = Column(String(30),nullable=False)
    domicilio =Column(String(255))
    correo = Column(String(100),unique=False)
    estado = Column(Boolean,default=True)
    tipoClave_id = Column(Integer, ForeignKey('tiposClave.id'), nullable=False)
    tipoClave = relationship("TipoClaves")
    idTipoPersona = Column(Integer, ForeignKey('tipoPersona.idTipoPersona'), nullable=False)
    tipoPersona = relationship("TipoPersona")
    # defino como se representara al ser llamado
    def __repr__(self):
        return f"Cuit {self.cuit} {self.apellido} {self.nombre}"
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedObject) the bigint data type does not have a default operator class for the "gist" accessor
TIP: You must specify an operator class for the index, or define a default operator class for the data type.
[SQL: 
CREATE TABLE transaction (
    id BIGSERIAL NOT NULL, 
    native_transaction_id BIGINT, 
    issued_at TIMESTAMP WITHOUT TIME ZONE, 
    client_addr INET, 
    PRIMARY KEY (id), 
    CONSTRAINT transaction_unique_native_tx_id EXCLUDE USING gist (native_transaction_id WITH =, tsrange(issued_at - INTERVAL '1 hour', issued_at) WITH &&)
)

]
(Background on this error at: http://sqlalche.me/e/13/f405)
kvesteri commented 3 years ago

Create the btree_gin extension using SQL: CREATE EXTENSION btree_gin

EnriqueGautoSand commented 3 years ago

i run that "CREATE EXTENSION btree_gin" in sql and create the extension but trouble persists im using Flask 1.0.2 Python 3.7.0 and postgresql 12 on windows

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedObject) the bigint data type does not have a default operator class for the "gist" accessor
TIP: You must specify an operator class for the index, or define a default operator class for the data type.
[SQL: 
CREATE TABLE transaction (
    id BIGSERIAL NOT NULL, 
    native_transaction_id BIGINT, 
    issued_at TIMESTAMP WITHOUT TIME ZONE, 
    client_addr INET, 
    PRIMARY KEY (id), 
    CONSTRAINT transaction_unique_native_tx_id EXCLUDE USING gist (native_transaction_id WITH =, tsrange(issued_at - INTERVAL '1 hour', issued_at) WITH &&)
)

]
(Background on this error at: http://sqlalche.me/e/13/f405)
EnriqueGautoSand commented 3 years ago

working with "CREATE EXTENSION btree_gist ; " thank you man!!!