Repository: frictionlessdata/frictionless-py

Issue:
Query(limit_rows=0) doesn't limit rows
# Overview

From here - https://github.com/frictionlessdata/frictionless-py/issues/516. Also the same must be for limit_fields


Discussion:

Patch:
diff --git a/frictionless/query.py b/frictionless/query.py
index 3315f852..247992c2 100644
--- a/frictionless/query.py
+++ b/frictionless/query.py
@@ -170,11 +170,11 @@ class Query(Metadata):
         "properties": {
             "pickFields": {"type": "array"},
             "skipFields": {"type": "array"},
-            "limitFields": {"type": "number"},
-            "offsetFields": {"type": "number"},
+            "limitFields": {"type": "number", "minimum": 1},
+            "offsetFields": {"type": "number", "minimum": 1},
             "pickRows": {"type": "array"},
             "skipRows": {"type": "array"},
-            "limitRows": {"type": "number"},
-            "offsetRows": {"type": "number"},
+            "limitRows": {"type": "number", "minimum": 1},
+            "offsetRows": {"type": "number", "minimum": 1},
         },
     }


Test patch:
diff --git a/tests/test_table.py b/tests/test_table.py
index 97d23601..f269c50c 100644
--- a/tests/test_table.py
+++ b/tests/test_table.py
@@ -851,6 +851,50 @@ def test_table_limit_offset_rows():
         assert table.read_data() == [["3", "c"], ["4", "d"]]
 
 
+def test_table_limit_fields_error_zero_issue_521():
+    source = "data/long.csv"
+    query = Query(limit_fields=0)
+    table = Table(source, query=query)
+    with pytest.raises(exceptions.FrictionlessException) as excinfo:
+        table.open()
+    error = excinfo.value.error
+    assert error.code == "query-error"
+    assert error.note.count('minimum of 1" at "limitFields')
+
+
+def test_table_offset_fields_error_zero_issue_521():
+    source = "data/long.csv"
+    query = Query(offset_fields=0)
+    table = Table(source, query=query)
+    with pytest.raises(exceptions.FrictionlessException) as excinfo:
+        table.open()
+    error = excinfo.value.error
+    assert error.code == "query-error"
+    assert error.note.count('minimum of 1" at "offsetFields')
+
+
+def test_table_limit_rows_error_zero_issue_521():
+    source = "data/long.csv"
+    query = Query(limit_rows=0)
+    table = Table(source, query=query)
+    with pytest.raises(exceptions.FrictionlessException) as excinfo:
+        table.open()
+    error = excinfo.value.error
+    assert error.code == "query-error"
+    assert error.note.count('minimum of 1" at "limitRows')
+
+
+def test_table_offset_rows_error_zero_issue_521():
+    source = "data/long.csv"
+    query = Query(offset_rows=0)
+    table = Table(source, query=query)
+    with pytest.raises(exceptions.FrictionlessException) as excinfo:
+        table.open()
+    error = excinfo.value.error
+    assert error.code == "query-error"
+    assert error.note.count('minimum of 1" at "offsetRows')
+
+
 # Header