DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Data Privacy and Security: A Developer's Guide to Handling Sensitive Data With DuckDB
  • Using AUTHID Parameter in Oracle PL/SQL
  • Microsoft Azure Backup Service
  • MySQL Instant DDL: Metadata Locks, Waiting Writers, and Query Pileups

Trending

  • Part 4: Multi-Agent Orchestration — Pairing Goose With Quarkus Flow State Machines
  • Integrating Apache Spark With Drools: A Loan Approval Demo
  • Production-Grade LLM Regression Testing: Contracts, Evals, and Quality Gates
  • PII Detection Before RAG Ingestion: Screening Documents in C#

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. Databases
  4. Row Level Security in Hyperlambda and SQL

Row Level Security in Hyperlambda and SQL

Row level security in Hyperlambda and SQL is a declarative feature when generating your CRUD backend. One simple dropdown list, and it’s done!

By 
Thomas Hansen
DZone Core CORE ·
Sep. 03, 22 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
6.1K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

We’ve always had row-level security in Hyperlambda. However, as of today, row-level security in Hyperlambda and SQL is a declarative feature when generating your CRUD backend. Look at the below screenshot to understand.

simple table I

The above is a simple table I added to the Aista CRM plugin using SQL Studio. The idea is to have a single table where each user can store notes for later. The “owner” field is the username of who’s note the particular record belongs to. No users should have access to other users’ notes. This idea is called “row level security”. If you reproduce the above database table in SQL Studio then go to the CRUD Generator, and select your database and table, you’ll see something like this if you expand the “owner” column.

The above dropdown list allows you to “lock” your field to the username of the authenticated user. This feature will automatically generate all the code required to ensure row-level security on all CRUD operations. Creating records will automatically “inject” the username. The read will only return records belonging to the user. An update will only allow for updating records belonging to the user. And delete till only delete records belonging to the user.

This is a highly useful feature, and the CRUD Generator simply takes care of everything automatically for you. No coding is required from your side.

How Does It Work?

I must have said this a million times before, but it’s impossible to create something resembling our CRUD Generator without a meta-programming language. My reasons for repeating this, are because the first question people ask me when they see Aista Magic Cloud is; “Why didn’t you use PHP or Python? Why this ‘Hyperlambda’ thing?”

My answer is always the same; “It’s not possible without a meta-programming language. As far as I know, Hyperlambda is the only modern meta-programming language in existence.”

The reason is that the tiny dropdown list thing you see in the above screenshot will actually “dynamically inject” Hyperlambda code into a “Hyperlambda template”. This is only possible if you can treat code the same way you treat data. Implying you allow for querying the code semantically, to understand how it works. This process resembles the same process you’re following as you’re injecting HTML elements into your DOM. HTML is a “semantic” language, meaning it’s got no “compilation” occurring. Fundamentally HTML is simply a tree structure. Hyperlambda shares this trait with HTML, it’s just a tree!

This allows the CRUD Generator, and other concepts for the record, to semantically inspect the Hyperlambda, and dynamically inject additional snippets at the correct place, according to your instructions.

Doing this with PHP, Python, C# or Java is not even possible in THEORY!

Below is the SQL necessary to recreate the above table in SQL Studio for your reference.

MySQL
 
CREATE TABLE notes(
  note_id integer not null primary key autoincrement,
  content text not null,
  owner text not null
);
Database security sql

Published at DZone with permission of Thomas Hansen. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Data Privacy and Security: A Developer's Guide to Handling Sensitive Data With DuckDB
  • Using AUTHID Parameter in Oracle PL/SQL
  • Microsoft Azure Backup Service
  • MySQL Instant DDL: Metadata Locks, Waiting Writers, and Query Pileups

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook