<commit_before>from flask_login import UserMixin, current_user
from flask_sqlalchemy import BaseQuery
from sqlalchemy.sql import and_, or_
from werkzeug.security import generate_password_hash, check_password_hash
from datetime import datetime
from random import randint

from app.middleware import db
from app.constants import (USER_ROLES, DEFAULT_PASSWORD, PREFIXES, TICKET_WAITING,
                           TICKET_PROCESSED, TICKET_UNATTENDED)

mtasks = db.Table(
    'mtasks',
    db.Column('office_id', db.Integer, db.ForeignKey('offices.id'), primary_key=True),
    db.Column('task_id', db.Integer, db.ForeignKey('tasks.id'), primary_key=True))


class Mixin:
    @classmethod
    def get(cls, id=False, **kwargs):
        if id is None:
            # NOTE: depericated, but can awaken mighty dragons!
            return None

        if id is False and not kwargs:
            return cls.query.first()

        if id:
            kwargs['id'] = id

        return cls.query.filter_by(**kwargs).first()<commit_msg>Fix database mixin .get() handling edge-case.<commit_after>from flask_login import UserMixin, current_user
from flask_sqlalchemy import BaseQuery
from sqlalchemy.sql import and_, or_
from werkzeug.security import generate_password_hash, check_password_hash
from datetime import datetime
from random import randint

from app.middleware import db
from app.constants import (USER_ROLES, DEFAULT_PASSWORD, PREFIXES, TICKET_WAITING,
                           TICKET_PROCESSED, TICKET_UNATTENDED)

mtasks = db.Table(
    'mtasks',
    db.Column('office_id', db.Integer, db.ForeignKey('offices.id'), primary_key=True),
    db.Column('task_id', db.Integer, db.ForeignKey('tasks.id'), primary_key=True))


class Mixin:
    @classmethod
    def get(cls, id=False, **kwargs):
        if id is None:
            # NOTE: depericated, but can awaken mighty dragons!
            return None

        if id is False and not kwargs:
            return cls.query.first()

        if id is not False and id is not None:
            kwargs['id'] = id

        return cls.query.filter_by(**kwargs).first()
{'fraction_non_alphanumeric': 0.08974358974358974, 'fraction_numerical': 0.0, 'mean_word_length': 3.23943661971831, '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': '2705362', 'n_tokens_mistral': 653, 'n_tokens_neox': 630, 'n_words': 184}