Hello, I've been struggling with this issue for the past couple of days and 
 would really, truly appreciate if someone could please give me pointers or 
direction as to what I might be missing.


Here are my models;
class Aggregate(db.Model):
    id = db.Column(UUID(as_uuid=True), primary_key=True,
                   server_default=db.text('uuid_generate_v4()'))
    blocks = db.relationship('AggregateBlock', cascade='all, delete-orphan',
                             passive_deletes=True, 
back_populates='aggregate')..


class AggregateBlock(db.Model):

    id = db.Column(UUID(as_uuid=True), primary_key=True,
                   server_default=db.text('uuid_generate_v4()'))
    block_id = db.Column(UUID(as_uuid=True),
                         db.ForeignKey('blocks.id', ondelete='CASCADE'), 
nullable=False, index=True)
    aggregate_id = db.Column(UUID(as_uuid=True),
                             db.ForeignKey('aggregates.id', ondelete=
'RESTRICT'), nullable=False)
    block = db.relationship('Block', back_populates='aggregates')
    aggregate = db.relationship('Aggregate', back_populates='blocks')


    

class Block(db.Model):
    id = db.Column(UUID(as_uuid=True), primary_key=True,
                   server_default=db.text('uuid_generate_v4()'))
    is_complete = db.Column(db.Boolean, default=False)
    aggregates = db.relationship('AggregateBlock', cascade='all, 
delete-orphan',
                                 passive_deletes=True, back_populates=
'block')


from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()

select = 
db.session.query(Aggregate).join(AggregateBlock).join(Block).filter(Block.is_complete
 
== complete)

print(len(select.all())

print(len(select.paginate(per_page=20).items())


If I do a select.all(), I get the right number of rows which is 47. 
 However, if I try to paginate for a per_page size say 20, I lot a less 
rows like 11.  
select.paginate(per_page=20).
The number could go up to 21 or so as I increase the page size.  Why would 
paginate decrease the number of returned records?

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/e5a14305-4e63-4467-9610-1faf3f8c8412o%40googlegroups.com.

Reply via email to