Skip to content

Conversation

@kagel
Copy link
Member

@kagel kagel commented Jan 3, 2024

No description provided.

if tenant_id:
g.tenant_id = tenant_id
else:
g.tenant_id = 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is it, "2"?


def _store_tenant_id_in_context():
g.tenant_id = None
tenant_id = request.headers.get("X-Tenant-ID")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose the PR is not complete, because I don't see how this value gets supplied from the frontend or something, right?

# Call the original filter method with the provided criteria
query = super(TenantScopedQuery, self).filter(*criteria)

logging.error(f"Query: {query}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it .error?

query_class = TenantScopedQuery

# Assuming every table has a 'company_id' field
company_id = db.Column(db.Integer, nullable=False, index=True)
Copy link
Member

@varnie varnie Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed here really? I see this company_id in all the descendants of this table which overwrite this one. I'd say yes, it is needed, but why do we have tons of company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete='SET NULL'), server_default="1", nullable=False) here and there if we can put this line directly into this class?


def filter_by(self, **kwargs):
logging.error(f"Filter by kwargs: {kwargs}")
super(TenantScopedQuery, self).filter_by(**kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this method return something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants