new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Supabase · Database · all subjects

arrays

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Create table with array column SQL syntax

To create a table with an array column in Postgres, use the syntax: CREATE TABLE tablename (column_name type ARRAY). For example: create table arraytest (id integer not null, textarray text array);

Insert array values with SQL

To insert an array value using SQL, use the ARRAY keyword with the syntax: INSERT INTO table (column) VALUES (ARRAY['value1', 'value2', 'value3']). Example: INSERT INTO arraytest (id, textarray) VALUES (1, ARRAY['Harry', 'Larry', 'Moe']);

Postgres array indexing is 1-based

Postgres uses 1-based indexing for arrays, not 0-based. The first item in an array is accessed with textarray[1], not textarray[0].

Query specific array element with SQL

To select a specific element from an array column in SQL, use 1-based indexing with bracket notation. Example: SELECT textarray[1] FROM arraytest; returns the first element.

Get array length with SQL

To get the length of an array column in SQL, use the array_length function with the syntax: array_length(array_column, dimension). For a 1D array, the dimension is 1. Example: SELECT array_length(textarray, 1) FROM arraytest;

Insert array values with Swift client

To insert array values using the Swift client, define a struct conforming to Encodable with an array property, then use the insert method. The property type should be [String] or appropriate array type for the data.

Insert array values with Python client

To insert array values using the Python client, pass a dictionary with the array as a native Python list in the insert payload. Example: supabase.from_('arraytest').insert([{id: 2, textarray: ['one', 'two', 'three', 'four']}]).execute()

Insert array values with C# client

To insert array values using the C# client, define a class with a List<T> property for the array column, then use the Insert method. Example: await supabase.From<ArrayTest>().Insert(new ArrayTest { Id = 2, Textarray = new List<string> { "one", "two", "three", "four" } });

Give your agent this brain