Comments (2)
Yeah, only works like this in where clauses right now. Will look into it
from peewee.
I'm actually not sure whether this is a valid use-case -- in your example you are querying for the first letter of a constant ("myFirstName") -- what is the benefit of doing that?
I'm assuming the query you're hoping to generate is something like (using sqlite style parameter interpolation):
>>> query = User.select(['id', 'username', R('LOWER(SUBSTR( %s, 1, 1))', 'myFirstName' , 'first_letter')])
>>> query.sql()
('SELECT "id", LOWER(SUBSTR(?, 1, 1)) AS first_letter FROM "users"', ['myFirstName'])
But if you know the "first_letter" is always going to be 'm' why add it to the query? If you hope to use that alias as part of the where clause you could instead write:
>>> query = User.select().where(R('LOWER(SUBSTR(username, 1, 1))=%s', 'm'))
>>> query.sql()
('SELECT "id", "username" FROM "users" WHERE LOWER(SUBSTR(username, 1, 1))=?', ['m'])
Am I missing something? I've got this written in a branch but as I was thinking about it I had a hard time thinking of how it would be useful. Thanks!
from peewee.
Related Issues (20)
- Feature Request: Encrypted Field in playhouse.fields HOT 2
- how to use migrator alter_column_type? HOT 1
- Fields are missing in model HOT 2
- Redundant Database Queries Occurring In Select Operations When No Data Is Present HOT 3
- Wrong CursorWrapper __bool__
- Subqueries inside `fn.SUM(Case(...))` fail because the subquery is not wrapped with parentheses HOT 1
- Deadlock in SqliteQueueDatabase when calling stop() HOT 12
- PostgreSQL: pwiz doesn't generate field for primary key column HOT 1
- Undocumented breaking change (or bug?) in 3.15.0 HOT 2
- SqliteQueueDatabase pause(), unpause() do not block the caller HOT 7
- Transaction feature for SqliteQueueDatabase HOT 1
- [Question] Block the possibility to change the default value HOT 1
- How do I add a ForeignKeyField to a model that is not yet defined? HOT 1
- Is it possible to cache a field? HOT 1
- [Question] join Not unique table/alias: 't2' HOT 10
- Full text search with queries HOT 1
- Implement __deepcopy__ and __copy__ methods in Node HOT 10
- Connection won't be recycled after a while HOT 1
- Question regarding transferring tables between two databases HOT 1
- support for fn.PERCENTILE_CONT HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from peewee.