Issue 1:
Describe the bug

We had a legacy enum with names that have spaces so we added some aliases to make coding easier.

Notice the aliases have repeated values so they will not create enum elements.

E.g:

Names = enum.Enum(
value='Names',
names=[
('Name A', 1), ('a', 1),
('Name B', 2), ('b', 2),
('Name C', 3), ('c', 3),
]
)

So when you list(Names), you only see the 3 original enum names and : Names["Name A"] is Names.a meaning that a is just an alias and points to the same object.

When you pass this to name = Column(Enum(Names)), it will create the 6 names on the column because

sqlalchemy.Enum._parse_into_values is using the __members__ atribute from enum which shows everything, including aliases.

SQL output for that column:

`name` ENUM('Name A','Name B','Name C','a','b','c') NOT NULL,

Expected behavior

`name` ENUM('Name A','Name B','Name C') NOT NULL,

I propose to use [e.name for e in enum_class]

instead of enum_class.__members__

sqlalchemy/lib/sqlalchemy/sql/sqltypes.py

Line 1509
in
93ea31d

members = self.enum_class.__members__

Versions.

OS: MacOS

Python: 3.8

SQLAlchemy: 1.3.23

Database: MySQL

DBAPI: pymysql

Issue 2:
Migrated issue, originally created by Lev Panov (@leavittx)

Engine instance was created via

#!div style="font-size: 80%"
Code highlighting:
`#!python
engine = create_engine('mssql+pyodbc://user:pass@server.com/db?driver=SQL Server', echo=True)

When I do for example

#!div style="font-size: 80%"
Code highlighting:
`#!python
session.query(User).filter(or_(expression.false(), expression.true())).all()

Output:

2013-09-15 23:40:11,761 INFO sqlalchemy.engine.base.Engine SELECT [user](user).id AS user_id, [user](user).name AS user_name
FROM [user](user)
WHERE 0 OR 1
2013-09-15 23:40:11,761 INFO sqlalchemy.engine.base.Engine ()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\orm\query.py", line 2249, in all
return list(self)
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\orm\query.py", line 2361, in __iter__
return self._execute_and_instances(context)
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\orm\query.py", line 2376, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\engine\base.py", line 661, in execute
params)
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\engine\base.py", line 762, in _execute_clauseelement
compiled_sql, distilled_params
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\engine\base.py", line 875, in _execute_context
context)
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\engine\base.py", line 1019, in _handle_dbapi_exception
exc_info
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\util\compat.py", line 197, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=exc_value)
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\util\compat.py", line 190, in reraise
raise value.with_traceback(tb)
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\engine\base.py", line 868, in _execute_context
context)
File "C:\Python33\lib\site-packages\sqlalchemy-0.9.0dev-py3.3-win-amd64.egg\sqlalchemy\engine\default.py", line 372, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', "[42000](42000) [Microsoft](Microsoft)[SQL Server Driver](ODBC)[Server](SQL)An expression of non-boolean type specified in a context where a condition is expected, near 'OR'. (4145) (SQLExecDirectW)") 'SELECT [user](user).id AS user_id, [user](user).name AS user_name \nFROM [user](user) \nWHERE 0 OR 1' ()