Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to create an empty DatabaseQueryFilter to fetch all rows from a database #14

Closed
AsFal opened this issue May 25, 2021 · 3 comments

Comments

@AsFal
Copy link
Contributor

AsFal commented May 25, 2021

Description

Impossible to create a DatabaseQuery with an empty DatabseQueryFilter. Fields that do not have empty values (such as embedded structs) cannot be omitted. Source

To Reproduce

Populate your environment variables with valid values for NOTION_SECRET_API_KEY and NOTION_DATABASE_ID and run the following code.

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/dstotijn/go-notion"
)

func main() {
	client := notion.NewClient(os.Getenv("NOTION_SECRET_API_KEY"))
	rows, err := client.QueryDatabase(context.Background(), os.Getenv("NOTION_DATABASE_ID"), &notion.DatabaseQuery{
		PageSize: 10,
	})
	fmt.Println("======= ERROR ======")
	fmt.Println(err)
	fmt.Println("======= ROWS ======")
	fmt.Println(rows)
}

Given the following table
Screen Shot 2021-05-24 at 10 10 24 PM
I go the following error
Screen Shot 2021-05-24 at 10 11 24 PM

@AsFal AsFal changed the title Impossible to create an empty DatabaseFilterQuery to fetch all rows from a database Impossible to create an empty DatabaseQueryFilter to fetch all rows from a database May 25, 2021
@maksim77
Copy link

Just specify nil instead &notion.DatabaseQuery

@AsFal
Copy link
Contributor Author

AsFal commented May 25, 2021

Specifying nil for &notion.DatabaseQuery wouldn't allow the use of an empty filter with custom Sort, StartCursor, or PageSize values. This would prevent fetching all the entries from a database with more than 100 entries given the page size limit.

@dstotijn
Copy link
Owner

Fixed and released in v0.3.2.

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

No branches or pull requests

3 participants