Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:25:41+00:00 2026-05-27T20:25:41+00:00

I save email addresses in two tables: userid and domain. The model looks something

  • 0

I save email addresses in two tables: userid and domain. The model looks something like this:

class Email():
    id = Column(Integer, primary_key=True)
    parent_id = Column(Unicode, ForeignKey('domain.id'))
    parent = relationship('Domain')
    userid = Column(Unicode)

class Domain():
    id = Column(Integer, primary_key=True)
    host = Column(Unicode)

I suddenly started having issues with joins. When I do the following, I always get None:

def get_email(email):
    fragments = email.lower().split(u'@')
    return DBSession().query(Email).filter(Email.userid == fragments[0]).join(Domain, Domain.id == Email.parent_id).filter(Domain.host == fragments[1]).first()

But if I separate this join into two queries, I retrieve the correct object:

def get_email(email):
    fragments = email.lower().split(u'@')
    session = DBSession()
    thehost = session.query(Domain).filter(Domain.host == fragments[1]).first()
    return session.query(Email).filter(Email.userid == fragments[0]).filter(Email.parent_id == thehost.id).first()

Anyone know what I’m doing wrong, or how I should go about troubleshooting? I spent the last 30 minutes to no avail… Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:25:42+00:00Added an answer on May 27, 2026 at 8:25 pm

    Figured out the problem. Had to do with inheritance and aliasing. Lesson: If joining two objects inherited from the same object, alias at least one of the objects!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ajax request that do 3 missions: Save Model (DB) Send Email Give
I have a type I want to save to the database, say, email addresses,
This question is more theoretical. Is it save to be passing email address in
I'd like some advice on how I should synchronize a list of email addresses
I have two classes, namely User & UserProfile User contains(few attributes like):- userId loginId
I have two domain classes: User : class User { String login String password
I am trying to create & save images from data in an email from
We save and read files by (de) serializing a class named DocumentClass. All was
I am trying to upload two images, re-size them, and then save them in
I've got a Users table with an Email column in my database. I've also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.